Enabled selection of cipher mode (defaults to CBC), added method to conveniently create AES SymmetricCryptoStream.
This commit is contained in:
parent
458acfcd85
commit
1eb93d2f9a
|
|
@ -4,13 +4,24 @@ namespace Proculite.Common.Security.Cryptography
|
|||
{
|
||||
public static class SimpleAes
|
||||
{
|
||||
public static Aes Create(byte[] key, byte[] iv)
|
||||
public static Aes Create(byte[] key, byte[] iv, CipherMode cipherMode = CipherMode.CBC)
|
||||
{
|
||||
Aes aes = Aes.Create();
|
||||
aes.IV = iv;
|
||||
aes.Key = key;
|
||||
aes.Mode = cipherMode;
|
||||
|
||||
return aes;
|
||||
}
|
||||
|
||||
public static SymmetricCryptoStream CreateCryptoStream(
|
||||
byte[] key,
|
||||
byte[] iv,
|
||||
CipherMode cipherMode = CipherMode.CBC
|
||||
)
|
||||
{
|
||||
Aes aes = Create(key, iv, cipherMode);
|
||||
return new SymmetricCryptoStream(aes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue