SHA2
functionsupportedCore SQL functionsReturns a hex-encoded string containing the N-bit SHA-2 message digest, where N is the specified output digest size. These functions are synonymous.
Syntax
supportedpartialnot supportednot scored
SHA2( <msg> [, <digest_size>] )
SHA2_HEX( <msg> [, <digest_size>] )
Parameters
| Name | Required | Description |
|---|---|---|
msg | required | A string expression, the message to be hashed |
digest_size | optional | Size (in bits) of the output, corresponding to the specific SHA-2 function used to encrypt the string: 224 = SHA-224 256 = SHA-256 (Default) 384 = SHA-384 512 = SHA-512 SHA-512/224 and SHA-512/256 are not supported. |
Returns
The data type of the returned value is VARCHAR.
Usage notes
- Do not use this function to encrypt a message that you need to decrypt. This function has no corresponding decryption function. (The length of the output is independent of the length of the input. The output does not necessarily have enough bits to hold all of the information from the input, so it is not possible to write a function that can decrypt all possible valid inputs.) This function is intended for other purposes, such as calculating a checksum to detect data corruption. If you need to encrypt and decrypt data, use the following functions: ENCRYPT and DECRYPT
- ENCRYPT_RAW and DECRYPT_RAW