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,
	bool useBinHex)

Return Value

Hash value formatted as a base64-encoded or BinHex stringstring.

Parameters

plainText
Plaintext value to be hashed.

hashAlgorithm
Name of the hash algorithm. Allowed values are: "MD5", "SHA1", "SHA256", "SHA384", "SHA512", "HMACMD5", "HMACSHA1", "HMACSHA256", "HMACSHA512" (if any other value is specified MD5 will be used).

        HMAC algorithms uses Hash-based Message Authentication Code.
        The HMAC process mixes a secret key with the message data, hashes 
        the result with the hash function, mixes that hash value with 
        the secret key again, and then applies the hash function
        a second time. HMAC hashes are fixed lenght and generally
        much longer than non-HMAC hashes of the same type.
        
        https://msdn.microsoft.com/en-us/library/system.security.cryptography.hmacsha256(v=vs.110).aspx      
        
        This value is case-insensitive.

saltBytes
useBinHex
if true returns the data as BinHex byte pair string. Otherwise Base64 is returned.

Overloads:


See also:

Class Encryption

© West Wind Technologies, 1996-2020 • Updated: 07/15/20
Comment or report problem with topic