Hashes any of several types of source data using the specified hashing algorithm, and returns a RAW message digest value whose size and security depends on the algorithm.
A key value to use in the hash operation for the hashing algorithms. The key may be of type CHARACTER, LONGCHAR, RAW, or MEMPTR. If the key is a CHARACTER or LONGCHAR value, the AVM converts it to UTF-8 (which ensures a consistent value regardless of code page settings). To avoid this automatic conversion, specify a RAW or MEMPTR value. This key value is used along with the source data during the hash operation.
For the HMAC algorithms, it is strongly recommended that you specify a hash key (preferably a randomly generated one).
If hash-key is not specified it defaults to the empty string ("").
If either data-to-hash or hash-key is the Unknown value (?), then the Unknown value (?) is returned from the function.
If the hash-key value contains a null character, the null character is included in the hash operation.
The following example demonstrates how to use the MESSAGE-DIGEST function.
DEFINE VARIABLE mydata AS CHARACTER NO-UNDO INITIAL "My data to hash". DEFINE VARIABLE hashkey AS CHARACTER NO-UNDO INITIAL "My hash key". DEFINE VARIABLE mdvalue AS RAW NO-UNDO. mdvalue = MESSAGE-DIGEST("SHA-512", mydata, hashkey). MESSAGE "LENGTH: " LENGTH(mdvalue) SKIP "VALUE: " STRING(mdvalue) VIEW-AS ALERT-BOX. |