We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bec6572 commit ea99cd0Copy full SHA for ea99cd0
1 file changed
Encrypt/Encrypt.cs
@@ -0,0 +1,28 @@
1
+using System.IO;
2
+using System.Security.Cryptography;
3
+
4
+namespace SafeCrypt
5
+{
6
+ public class Encrypt
7
+ {
8
+ // Method to encrypt data using AES algorithm
9
+ public static byte[] EncryptAES(byte[] data, byte[] key, byte[] iv)
10
11
+ using (Aes aes = Aes.Create())
12
13
+ aes.Key = key;
14
+ aes.IV = iv;
15
+ ICryptoTransform encryptor = aes.CreateEncryptor(aes.Key, aes.IV);
16
+ using (MemoryStream memoryStream = new MemoryStream())
17
18
+ using (CryptoStream cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write))
19
20
+ cryptoStream.Write(data, 0, data.Length);
21
+ cryptoStream.FlushFinalBlock();
22
+ return memoryStream.ToArray();
23
+ }
24
25
26
27
28
+}
0 commit comments