SHA2DIGEST224, SHA2DIGEST256, SHA2DIGEST384, and SHA2DIGEST512
Perform a SHA-2 hash of the text specified by an address and length and return a CHAR string with that hash value.
- p
- A pointer that specifies the address of a buffer to be hashed.
- n
- An expression that specifies the length (in bytes) of that buffer. It must have a computational type and will be converted to type size_t.
The length returned is one eighth of the bit length in the function name, so, for example, SHA2DIGEST256 returns a CHAR(32) value.
These functions generate code that executes the KLMD assembler instruction.
Examples
The following example performs a 512-bit SHA-2 hash of the text in a CHARACTER variable c.
dcl encoded char(64);
encoded = sha2digest512(addrdata(c), length(c));