CryptAuthCode
Returns a binary HMAC (keyed-hash message authentication code) using the specified cryptographic hash algorithm.
Format
CryptAuthCode ( data ; algorithm ; key )
Parameters
data
- any text expression or field from which to generate the HMAC.
algorithm
- the name of the cryptographic algorithm to use (see below).
key
- any expression or field as the key to encode the hash with.
Data type returned
container
Originated in version
16.0
Description
Use the Base64EncodeRFC and Base64Decode or HexEncode and HexDecode functions to control the encoding of the key and the returned HMAC.
For the algorithm
parameter, use one of the following names to specify the cryptographic algorithm:
-
MD5
-
SHA1
-
SHA224
-
SHA256
-
SHA384
-
SHA512
If algorithm
is empty (""), the SHA512 algorithm is used; an unrecognized name causes this function to return "?".
Example 1
In the Results container field, stores a file containing an HMAC of the text in the Message field. The HMAC is encoded with the value in the Key field using the default algorithm.
Set Field [ Table::Results ; CryptAuthCode ( Table::Message ; "" ; Table::Key ) ]
Example 2
Returns an HMAC of the contents of the $JSON variable using the SHA512 algorithm and a hex-encoded key $Key. The container data returned by CryptAuthCode is returned as Base64-encoded text.
Base64EncodeRFC ( 4648; CryptAuthCode ( $JSON ; "SHA512" ; HexDecode ( $Key ; "key.data" ) ) )