Class AesCryptor
- Namespace
- Cuemon.Security.Cryptography
- Assembly
- Cuemon.Security.Cryptography.dll
Provides an implementation of the Advanced Encryption Standard (AES) symmetric algorithm.
public class AesCryptor
- Inheritance
-
AesCryptor
Constructors
AesCryptor()
Initializes a new instance of the AesCryptor class.
public AesCryptor()
AesCryptor(byte[], byte[])
Initializes a new instance of the AesCryptor class.
public AesCryptor(byte[] key, byte[] initializationVector)
Parameters
keybyte[]The secret key of this instance.
initializationVectorbyte[]The initialization vector (IV) of this instance.
Exceptions
- ArgumentNullException
keycannot be null -or-initializationVectorcannot be null.- CryptographicException
keydoes not meet the required fixed size of either 128 bits, 192 bits or 256 bits -or-initializationVectordoes not meet the required fixed size of 128 bits.
Fields
BlockSize
Gets the block size (bits) for the Advanced Encryption Standard (AES) symmetric algorithm.
public const byte BlockSize = 128
Field Value
Properties
InitializationVector
Gets the initialization vector (IV) of this instance.
public byte[] InitializationVector { get; }
Property Value
- byte[]
The initialization vector (IV) of this instance.
Key
Gets the secret key of this instance.
public byte[] Key { get; }
Property Value
- byte[]
The secret key of this instance.
Methods
Decrypt(byte[], Action<AesCryptorOptions>)
Decrypts the specified value.
public byte[] Decrypt(byte[] value, Action<AesCryptorOptions> setup = null)
Parameters
valuebyte[]The encrypted value that needs to be decrypted.
setupAction<AesCryptorOptions>The AesCryptorOptions which may be configured.
Returns
- byte[]
The decrypted value.
Encrypt(byte[], Action<AesCryptorOptions>)
Encrypts the specified value.
public byte[] Encrypt(byte[] value, Action<AesCryptorOptions> setup = null)
Parameters
valuebyte[]The value to encrypt.
setupAction<AesCryptorOptions>The AesCryptorOptions which may be configured.
Returns
- byte[]
The encrypted value.
GenerateInitializationVector()
Generates a random 128 bit initialization vector (IV).
public static byte[] GenerateInitializationVector()
Returns
- byte[]
A random 128 bit generated initialization vector (IV).
GenerateKey(Action<AesKeyOptions>)
Generates a secret key from the options defined in setup.
public static byte[] GenerateKey(Action<AesKeyOptions> setup = null)
Parameters
setupAction<AesKeyOptions>The AesKeyOptions which may be configured.
Returns
- byte[]
A secret key from the options defined in
setup.