Encoding and hashing built-in functions
The encoding and hashing built-in functions allow you to encode, decode, and hash buffers of text.
Table 1 lists the encoding and hashing built-in functions and a short description of each.
| Function | Description |
|---|---|
|
BASE64DECODE |
Decodes the source buffer from base 64 that is encoded as CHARACTER. Returns a size_t value that indicates the number of bytes that are written into the target buffer. |
| BASE64DECODE8 | Decodes the source buffer from base 64 that is encoded as UTF-8. Returns a size_t value that indicates the number of bytes that are written into the target buffer. |
| BASE64DECODE16 | Decodes the source buffer from base 64 that is encoded as UTF-16. Returns a size_t value that indicates the number of bytes that are written into the target buffer. |
| BASE64ENCODE | Encodes the source buffer into base 64 that is encoded as CHARACTER. Returns a size_t value that indicates the number of bytes that are written into the target buffer. |
| BASE64ENCODE8 | Encodes the source buffer into base 64 that is encoded as UTF-8. Returns a size_t value that indicates the number of bytes that are written into the target buffer. |
| BASE64ENCODE16 | Encodes the source buffer into base 64 that is encoded as UTF-16. Returns a size_t value that indicates the number of bytes that are written into the target buffer. |
| CHECKSUM | Returns the checksum value for a specified buffer. |
| HEXDECODE | Decodes a source buffer from base 16 that is encoded in the character set specified by the ASCII/EBCDIC suboption of the DEFAULT compiler option. Returns a size_t value that indicates the number of bytes that are written into the target buffer. |
| HEXDECODE8 | Decodes a source buffer from base 16 that is encoded in UTF-8. Returns a size_t value that indicates the number of bytes that are written into the target buffer. |
| SHA1DIGEST | Performs a SHA-1 hash of the text specified by an address and length and returns a CHAR(20) string with that hash value. |
| SHA1FINAL | Uses a token initialized by the corresponding SHA1INIT function to complete a SHA-1 hash of a series of texts and returns a CHAR(20) string with that hash value. |
| SHA1INIT | Returns a token (of type POINTER) that can be used with the corresponding SHA1UPDATE and SHA1FINAL functions to hash a series of texts. |
| SHA1UPDATE | Uses a token initialized by the corresponding SHA1INIT function to perform an intermediate hash of an element in a series of texts. |
| SHA2DIGESTx |
Performs a SHA-2 hash of the text specified by an address and length and returns a CHAR string with that hash value. |
| SHA2FINALx | Uses a token initialized by the corresponding SHA2INIT function to complete a SHA-2 hash of a series of texts and returns a CHAR string with that hash value. |
| SHA2INITx | Returns a token (of type POINTER) that can be used with the corresponding SHA2UPDATE and SHA2FINAL functions to hash a series of texts. |
| SHA2UPDATEx | Uses a token initialized by the corresponding SHA2INIT function to perform an intermediate hash of an element in a series of texts. |
| SHA3DIGESTx | Performs a SHA-3 hash of the text specified by an address and length and return a CHAR string with that hash value. |
| SHA3FINALx | Uses a token initialized by the corresponding SHA3INIT function to complete a SHA-3 hash of a series of texts and returns a CHAR string with that hash value. |
| SHA3INITx | Returns a token (of type POINTER) that can be used with the corresponding SHA3UPDATE and SHA3FINAL functions to hash a series of texts. |
| SHA3UPDATEx | Uses a token initialized by the corresponding SHA3INIT function to perform an intermediate hash of an element in a series of texts. |
Notes:
- The x in the names of the SHA-2 and SHA-3 functions must be one of the values 224, 256, 384, or 512.
- The functions hex, hex8, heximage, heximage8, and unhex also support encoding into and decoding from hex, but these 5 functions all return character strings (while all of the functions in this category work on buffers of text and return integer values).