Skip to content

Commit 37f3cb3

Browse files
committed
add method to convert key and Iv from string to byte and return aseKey and aesIv
1 parent 1199b2b commit 37f3cb3

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

Encrypt/AesEncryption/AesEncryption.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ public byte[] AesEncrypt(string data, string secretKey, string iv)
2727
public byte[] AesDecrypt(string data, string secretKey, string iv)
2828
{
2929
NullChecks(data, secretKey, iv);
30-
var convertedKeys = ConvertKeysToBytes(secretKey, iv);
30+
//var convertedKeys = ConvertKeysToBytes(secretKey, iv);
3131

32-
var aesKey = convertedKeys.Item1;
33-
var aesIv = convertedKeys.Item2;
32+
var (aesKey, aesIv) = ConvertKeysToBytesAndGetKeys(secretKey, iv);
33+
//var aesKey = convertedKeys.Item1;
34+
//var aesIv = convertedKeys.Item2;
3435

3536
var aesData = data.HexadecimalStringToByteArray();
3637
return DecryptAES(aesData, aesKey, aesIv);
@@ -101,6 +102,13 @@ private void NullChecks(string data, string secretKey, string iv)
101102

102103
return (secret, iv);
103104
}
105+
106+
private (byte[], byte[]) ConvertKeysToBytesAndGetKeys(string secretKey, string iv)
107+
{
108+
var convertedKeys = ConvertKeysToBytes(secretKey, iv);
109+
110+
return (convertedKeys.Item1, convertedKeys.Item2);
111+
}
104112
private void NullChecks(string data, string secretKey)
105113
{
106114
if (data == null || data.Length <= 0)

0 commit comments

Comments
 (0)