Skip to content

Commit b7b9bd5

Browse files
committed
Add overload method that accepts data and secret without Iv
1 parent 59d217e commit b7b9bd5

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

Encrypt/AesEncryption/Encrypt.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,18 @@ public byte[] AesEncrypt(string data, string secretKey, string iv)
1818
var aesData = data.HexadecimalStringToByteArray();
1919

2020
return EncryptAES(aesData, aesKey, aesIv);
21-
}
21+
}
22+
23+
public byte[] AesEncrypt(string data, string secretKey)
24+
{
25+
NullChecks(data, secretKey);
26+
27+
var aesIv = GenerateRandomBytes(16);
28+
var aesKey = Encoding.UTF8.GetBytes(secretKey);
29+
var aesData = data.HexadecimalStringToByteArray();
30+
31+
return EncryptAES(aesData, aesKey, aesIv);
32+
}
2233

2334
public string AesEncryptByteToHexString(byte[] data, byte[] secretKey, byte[] iv)
2435
{
@@ -66,5 +77,5 @@ private void NullChecks(string data, string secretKey)
6677
//{
6778

6879
//}
69-
}
80+
}
7081
}

0 commit comments

Comments
 (0)