44using System . Reflection ;
55using System . Security . Cryptography ;
66using System . Text ;
7+ using System . Threading . Tasks ;
78
89namespace SafeCrypt . AesEncryption
910{
@@ -25,7 +26,7 @@ public class BaseAesEncryption
2526 /// <exception cref="Exception">
2627 /// Thrown for general encryption-related exceptions.
2728 /// </exception>
28- internal static byte [ ] EncryptAES ( ByteEncryptionParameters param )
29+ internal static async Task < byte [ ] > EncryptAES ( ByteEncryptionParameters param )
2930 {
3031 try
3132 {
@@ -45,7 +46,7 @@ internal static byte[] EncryptAES(ByteEncryptionParameters param)
4546 using ( CryptoStream cryptoStream = new CryptoStream ( memoryStream , encryptor , CryptoStreamMode . Write ) )
4647 {
4748 // Write the data to be encrypted to the CryptoStream
48- cryptoStream . Write ( param . Data , 0 , param . Data . Length ) ;
49+ await cryptoStream . WriteAsync ( param . Data , 0 , param . Data . Length ) ;
4950 cryptoStream . FlushFinalBlock ( ) ;
5051
5152 // Return the encrypted data as a byte array
@@ -73,7 +74,7 @@ internal static byte[] EncryptAES(ByteEncryptionParameters param)
7374 /// <exception cref="ArgumentNullException">
7475 /// Thrown if the input encrypted data, key, or initialization vector is null.
7576 /// </exception>
76- internal static byte [ ] DecryptAES ( ByteDecryptionParameters param )
77+ internal static async Task < byte [ ] > DecryptAES ( ByteDecryptionParameters param )
7778 {
7879 try
7980 {
@@ -97,7 +98,7 @@ internal static byte[] DecryptAES(ByteDecryptionParameters param)
9798 using ( MemoryStream decryptedStream = new MemoryStream ( ) )
9899 {
99100 // Copy the decrypted data from the CryptoStream to the MemoryStream
100- cryptoStream . CopyTo ( decryptedStream ) ;
101+ await cryptoStream . CopyToAsync ( decryptedStream ) ;
101102 return decryptedStream . ToArray ( ) ;
102103 }
103104 }
0 commit comments