[Encrypt_HMAC] generates a keyed hash message authentication code for a given input and password. The tag requires a -Password parameter which specifies the key for the hash and a -Token parameter which specifies the text message which is to be hashed. These parameters should be specified as a string or as a byte stream.
The digest algorithm used for the hash can be specified using an optional -Digest parameter. The digest algorithm defaults to MD5. SHA1 is another common option. However, any of the digest algorithms returned by [Cipher_List: -Digest] can be used.
The output is a byte stream by default. -Base64 specifies the output should be a Base64 encoded string. -Hex specifies the output should be a hex format string like 0x0123456789abcdef. -Cram specifies the output should be in a cram hex format like 0123456789ABCDEF.
Note that [Encrypt_CramMD5] is equivalent to using this tag with the parameters -Digest='MD5' and -Cram.
Encrypt_HMAC('password', 'token') Encrypt_HMAC('password', 'token', -Digest='sha1') Encrypt_HMAC('password', 'token', -Digest='sha1', -Base64)
This example takes two local string variables #password and #token, as parameters, and hashes them using Secure Hash Algorithm SHA-1 encryption and Base64 encoding for use in a URL.
The results use local('password' = 'key for the hash') and local('token' = 'text message which is to be hashed')
var(hashed_result = Encrypt_HMAC( -token = 'text message which is to be hashed', -password = 'key for the hash', -digest='sha1', -Base64 ) ) $hashed_result
Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.