A hash provider for any hash algorithm which derives from HashAlgorithm.
Creates a new instance of HashCryptographer and initialize it as a salt disabled algorithm.
public Void HashCryptographer(algorithmType)
Name | Type | Summary |
---|---|---|
algorithmType | Type | The HashAlgorithm to use. |
Creates a new instance of HashCryptographer and initializes it.
public Void HashCryptographer(algorithmType, saltEnabled)
Name | Type | Summary |
---|---|---|
algorithmType | Type | The HashAlgorithm to use. |
saltEnabled | Boolean | true if salt sould be applied; otherwise false. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when algorithmType is null. |
ArgumentException | Thrown when algorithmType is not a HashAlgorithm. |
Gets the HashAlgorithm type.
public Type AlgorithmType { get; set; }
Compares a plain text input with a computed hash.
public Boolean CompareHash(plaintext, hashedtext)
true if plaintext hashed is equal to hashedtext, false otherwise.
Name | Type | Summary |
---|---|---|
plaintext | Byte[] | The input to compare with the hash. |
hashedtext | Byte[] | The hash value to compare with the input value. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when plaintext or hashedtext are null. |
ArgumentException | Thrown then hashedtext is zero bytes length. |
Compute the hash value of plain text.
public Byte[] ComputeHash(plaintext)
The computed hash code.
Name | Type | Summary |
---|---|---|
plaintext | Byte[] | The input to compute the hash for. |
Computes the hash value for stream. If stream is empty null is returned.
public Byte[] ComputeHash(stream)
The computed hash code.
Even if configured, Salt is not used by this method.
Name | Type | Summary |
---|---|---|
stream | Stream | The input Stream for wich to compute the hash. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when stream is null. |
Computes a hash with the specified salt.
protected Byte[] ComputeHashWithSalt(plaintext, salt)
The computed hash.
Name | Type | Summary |
---|---|---|
plaintext | Byte[] | The plain text to hash. |
salt | Byte[] | The hash salt. |
Extracts the salt value from the hashed text.
protected Byte[] ExtractSalt(hashedtext)
The extracted salt.
Name | Type | Summary |
---|---|---|
hashedtext | Byte[] | The hash from which to extract the salt. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when hashedtext is null. |