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(Byte[] byteData,
	string hashAlgorithm,
	Byte[] saltBytes,
	bool useBinHex)

Return Value

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

Parameters

byteData
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
Optional but recommended salt bytes to apply to the hash. If not passed the raw encoding is used. If salt is nullthe raw algorithm is used (useful for file hashes etc.) HMAC versions REQUIRE that salt is passed.

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

Overloads:


See also:

Class Encryption

© West Wind Technologies, 1996-2024 • Updated: 06/29/24
Comment or report problem with topic