Encryption.ComputeHash

Generates a hash for the given plain text value and returns a base64-encoded result. Before the hash is computed, a random salt is generated and appended to the plain text. This salt is stored at the end of the hash value, so it can be used later for hash verification.

public static string ComputeHash(string plainText,
	string hashAlgorithm,
	Byte[] saltBytes)

Return Value

Hash value formatted as a base64-encoded string.

Parameters

plainText
Plaintext value to be hashed.

hashAlgorithm
Name of the hash algorithm. Allowed values are: "MD5", "SHA1", "SHA256", "SHA384", and "SHA512" (if any other value is specified MD5 hashing algorithm will be used). This value is case-insensitive.

saltBytes
Salt bytes. This parameter can be null, in which case a random salt value will be generated.

Remarks

ComputeHash code provided as an example by Obviex at http://www.obviex.com/samples/hash.aspx As noted by Obviex themselves, code is definitely not optimally efficient. Should performance requirements necessitate improvement, this should be improved.


See also:

Class Encryption

© West Wind Technologies, 1996-2016 • Updated: 12/12/15
Comment or report problem with topic