Hash

(Engine-Level Function)

Description: Generates a hash - a text string of bytes - of the given string.
Returns: Text
Usage: Script only.
Function Groups: Cryptography
Related to: Encrypt | Decrypt |ImportKey | GetCryptoProvider
Format: Hash(PlainText[, AlgID, Seed, HashHandle, CSP])
Parameters:  
PlainText    
Required. Any text string to create a hash from.
AlgID
Specifies the algorithm to use when creating the hash. Valid options are as follows:  Defaults to  0  (SHA-1) if missing or invalid.

AlgID

Hash

0

SHA-1 (160 bit hash)

1

MD5    (128 bit hash)

2

SHA-2 (256 bit hash)

3

SHA-2 (384 bit hash)

4

SHA-2 (512 bit hash)

Seed
Optional text buffer, which will be used as a seed for the hash algorithm. The contents of the buffer will be pre-pended to the text from the first parameter when creating the hash.
HashHandle
Optional. LValue. If Invalid, a hashing handle for the given AlgID is created and used for this and subsequent calls that supply this handle. No output is generated until a call, with this handle, is made with an Invalid PlainText parameter, at which time the hash built up using the handle is returned. At that time, the handle is destroyed and the LValue invalidated.

For one-time hashing, the hash value is returned from this function as a text string of bytes. For progressive hashing the return value of this function is Invalid until a call with an Invalid PlainText parameter and a valid HashHandle is made.
CSP
Optional. The CSP to be used for hashing. This has the same type as used in ImportKey() and Encrypt(). Generated by a call to GetCryptoProvider.
Comments & Example

The use of a seed string is functionally equivalent to the following example, but will execute slightly faster.

	X = Hash(Concat("XYZ", "ABCDE"), 2);

Does not support CNG (Cryptography New Generation).