Table of Contents

Class KeyedHashFactory

Namespace
Cuemon.Security.Cryptography
Assembly
Cuemon.Security.Cryptography.dll

Provides access to factory methods for creating and configuring Hash instances based on KeyedCryptoHash<TAlgorithm>.

public static class KeyedHashFactory
Inheritance
KeyedHashFactory

Methods

CreateHmacCrypto(Byte[], KeyedCryptoAlgorithm, Action<ConvertibleOptions>)

Creates an instance of a HMAC cryptographic implementation that derives from KeyedCryptoHash<TAlgorithm> with the specified algorithm. Default is HmacSecureHashAlgorithm256.

public static Hash CreateHmacCrypto(byte[] secret, KeyedCryptoAlgorithm algorithm = KeyedCryptoAlgorithm.HmacSha256, Action<ConvertibleOptions> setup = null)

Parameters

secret Byte[]

The secret key for the encryption.

algorithm KeyedCryptoAlgorithm

The KeyedCryptoAlgorithm that defines the HMAC cryptographic implementation. Default is HmacSha256.

setup Action<ConvertibleOptions>

The ConvertibleOptions which may be configured.

Returns

Hash

A Hash implementation of the by parameter specified algorithm.

Exceptions

ArgumentNullException

secret cannot be null.

CreateHmacCryptoMd5(Byte[], Action<ConvertibleOptions>)

Creates an instance of HmacMessageDigest5.

public static Hash CreateHmacCryptoMd5(byte[] secret, Action<ConvertibleOptions> setup = null)

Parameters

secret Byte[]

The secret key for HmacMessageDigest5 encryption. The key can be any length, but if it is more than 64 bytes long it will be hashed (using SHA-1) to derive a 64-byte key. Therefore, the recommended size of the secret key is 64 bytes.

setup Action<ConvertibleOptions>

The ConvertibleOptions which may be configured.

Returns

Hash

A Hash implementation of HmacMessageDigest5.

Exceptions

ArgumentNullException

secret cannot be null.

CreateHmacCryptoSha1(Byte[], Action<ConvertibleOptions>)

Creates an instance of HmacSecureHashAlgorithm1.

public static Hash CreateHmacCryptoSha1(byte[] secret, Action<ConvertibleOptions> setup = null)

Parameters

secret Byte[]

The secret key for HmacSecureHashAlgorithm1 encryption. The key can be any length, but if it is more than 64 bytes long it will be hashed (using SHA-1) to derive a 64-byte key. Therefore, the recommended size of the secret key is 64 bytes.

setup Action<ConvertibleOptions>

The ConvertibleOptions which may be configured.

Returns

Hash

A Hash implementation of HmacSecureHashAlgorithm1.

Exceptions

ArgumentNullException

secret cannot be null.

CreateHmacCryptoSha256(Byte[], Action<ConvertibleOptions>)

Creates an instance of HmacSecureHashAlgorithm256.

public static Hash CreateHmacCryptoSha256(byte[] secret, Action<ConvertibleOptions> setup = null)

Parameters

secret Byte[]

The secret key for HmacSecureHashAlgorithm256 encryption. The key can be any length. However, the recommended size is 64 bytes. If the key is more than 64 bytes long, it is hashed (using SHA-256) to derive a 64-byte key. If it is less than 64 bytes long, it is padded to 64 bytes.

setup Action<ConvertibleOptions>

The ConvertibleOptions which may be configured.

Returns

Hash

A Hash implementation of HmacSecureHashAlgorithm256.

Exceptions

ArgumentNullException

secret cannot be null.

CreateHmacCryptoSha384(Byte[], Action<ConvertibleOptions>)

Creates an instance of HmacSecureHashAlgorithm384.

public static Hash CreateHmacCryptoSha384(byte[] secret, Action<ConvertibleOptions> setup = null)

Parameters

secret Byte[]

The secret key for HmacSecureHashAlgorithm384 encryption. The key can be any length. However, the recommended size is 128 bytes. If the key is more than 128 bytes long, it is hashed (using SHA-384) to derive a 128-byte key. If it is less than 128 bytes long, it is padded to 128 bytes.

setup Action<ConvertibleOptions>

The ConvertibleOptions which may be configured.

Returns

Hash

A Hash implementation of HmacSecureHashAlgorithm384.

Exceptions

ArgumentNullException

secret cannot be null.

CreateHmacCryptoSha512(Byte[], Action<ConvertibleOptions>)

Creates an instance of HmacSecureHashAlgorithm512.

public static Hash CreateHmacCryptoSha512(byte[] secret, Action<ConvertibleOptions> setup = null)

Parameters

secret Byte[]

The secret key for HmacSecureHashAlgorithm512 encryption. The key can be any length. However, the recommended size is 128 bytes. If the key is more than 128 bytes long, it is hashed (using SHA-384) to derive a 128-byte key. If it is less than 128 bytes long, it is padded to 128 bytes.

setup Action<ConvertibleOptions>

The ConvertibleOptions which may be configured.

Returns

Hash

A Hash implementation of HmacSecureHashAlgorithm512.

Exceptions

ArgumentNullException

secret cannot be null.