Skip to content

Commit e2112e7

Browse files
committed
Add GenerateRandomBytes in BaseAesEncryption class
1 parent 44644bd commit e2112e7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

Encrypt/AesEncryption/BaseAesEncryption.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,16 @@ public virtual byte[] EncryptAES(byte[] data, byte[] key, byte[] iv)
3333
throw;
3434
}
3535
}
36+
37+
// Method to generate a random byte array of given length
38+
public static byte[] GenerateRandomBytes(int length)
39+
{
40+
byte[] randomBytes = new byte[length];
41+
using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
42+
{
43+
rng.GetBytes(randomBytes);
44+
}
45+
return randomBytes;
46+
}
3647
}
3748
}

0 commit comments

Comments
 (0)