File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . IO ;
3+ using System . Security . Cryptography ;
4+
5+ namespace SafeCrypt
6+ {
7+ public class BaseAesEncryption
8+ {
9+ // Method to encrypt data using AES algorithm
10+ public virtual byte [ ] EncryptAES ( byte [ ] data , byte [ ] key , byte [ ] iv )
11+ {
12+ try
13+ {
14+ using ( Aes aes = Aes . Create ( ) )
15+ {
16+ aes . Key = key ;
17+ aes . IV = iv ;
18+ ICryptoTransform encryptor = aes . CreateEncryptor ( aes . Key , aes . IV ) ;
19+ using ( MemoryStream memoryStream = new MemoryStream ( ) )
20+ {
21+ using ( CryptoStream cryptoStream = new CryptoStream ( memoryStream , encryptor , CryptoStreamMode . Write ) )
22+ {
23+ cryptoStream . Write ( data , 0 , data . Length ) ;
24+ cryptoStream . FlushFinalBlock ( ) ;
25+
26+ return memoryStream . ToArray ( ) ;
27+ }
28+ }
29+ }
30+ }
31+ catch ( Exception ex )
32+ {
33+ throw ;
34+ }
35+ }
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments