Computes the hash of a sequence of bytes, using the currently selected algorithm.
Input Arguments
|
Output Arguments
|
Return Value
None
Examples
Hash a password using PBKDF2 algorithm (5000 iteration)
Define_Com Class(#PRIM_DC.UnicodeString) Name(#PasswordString)
Define_Com Class(#XPRIM_Binary) Name(#PasswordBytes)
Define_Com Class(#XPRIM_Binary) Name(#HashBytes)
Define_Com Class(#XPRIM_Crypto_Hash) Name(#HashGenerator)
. . .
* Assume #PasswordString contains the password to hash
* Convert password string (#PasswordString) into bytes
#PasswordBytes.FromStringUsingUTF8 String(#PasswordString)
* Set algorithm to PBKDF2, using 5000 iteration
#HashGenerator.UsePBKDF2 Iteration(5000)
* Calculate hash
#HashGenerator.Compute Input(#PasswordBytes) Result(#HashBytes)
* Get hash value as Base64 string, and put in #HASH field
#HASH := #HashBytes.AsBase64String