Skip to content

Commit 632b112

Browse files
committed
Add AesData class that returns Iv and encrypted data
1 parent b7b9bd5 commit 632b112

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

Encrypt/AesEncryption/Encrypt.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,23 @@ public byte[] AesEncrypt(string data, string secretKey, string iv)
2020
return EncryptAES(aesData, aesKey, aesIv);
2121
}
2222

23-
public byte[] AesEncrypt(string data, string secretKey)
23+
public AesData AesEncrypt(string data, string secretKey)
2424
{
2525
NullChecks(data, secretKey);
2626

2727
var aesIv = GenerateRandomBytes(16);
2828
var aesKey = Encoding.UTF8.GetBytes(secretKey);
2929
var aesData = data.HexadecimalStringToByteArray();
3030

31-
return EncryptAES(aesData, aesKey, aesIv);
31+
var response = EncryptAES(aesData, aesKey, aesIv);
32+
33+
var responseData = new AesData
34+
{
35+
Data = response,
36+
Iv = aesIv
37+
};
38+
39+
return responseData;
3240
}
3341

3442
public string AesEncryptByteToHexString(byte[] data, byte[] secretKey, byte[] iv)
@@ -77,5 +85,11 @@ private void NullChecks(string data, string secretKey)
7785
//{
7886

7987
//}
80-
}
88+
}
89+
90+
public class AesData
91+
{
92+
public byte[] Data { get; set; }
93+
public byte[] Iv { get; set; }
94+
}
8195
}

0 commit comments

Comments
 (0)