Table of Contents

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
Object
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

key Byte[]

The secret key of this instance.

initializationVector Byte[]

The initialization vector (IV) of this instance.

Exceptions

System.ArgumentNullException

key cannot be null -or- initializationVector cannot be null.

System.Security.Cryptography.CryptographicException

key does not meet the required fixed size of either 128 bits, 192 bits or 256 bits -or- initializationVector does 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

Byte

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

value Byte[]

The encrypted value that needs to be decrypted.

setup Action<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

value Byte[]

The value to encrypt.

setup Action<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

setup Action<AesKeyOptions>

The AesKeyOptions which may be configured.

Returns

Byte[]

A secret key from the options defined in setup.