Skip to content

Commit 7ecf082

Browse files
committed
Add AesEncrypt method that accepts string as parameters for encryption
1 parent 2a56bc5 commit 7ecf082

2 files changed

Lines changed: 11 additions & 29 deletions

File tree

Encrypt/AesEncryption/Encrypt.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ public class Encrypt : BaseAesEncryption
88
{
99
public byte[] AesEncrypt(byte[] data, byte[] secretKey, byte[] iv)
1010
=> EncryptAES(data, secretKey, iv);
11-
11+
12+
public byte[] AesEncrypt(string data, string secretKey, string iv)
13+
{
14+
NullChecks(data, secretKey, iv);
15+
16+
var aesKey = Encoding.UTF8.GetBytes(secretKey);
17+
var aesIv = Encoding.UTF8.GetBytes(iv);
18+
var aesData = data.HexadecimalStringToByteArray();
19+
20+
return EncryptAES(aesData, aesKey, aesIv);
21+
}
1222

1323
public string AesEncryptByteToHexString(byte[] data, byte[] secretKey, byte[] iv)
1424
{

Encrypt/Encrypt.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)