SHA2()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns an SHA-2 checksum hash as a hexadecimal string.
USAGE
SHA2(string, hash_length)
Argument Name | Description |
---|---|
| The string to be hashed |
| The bit length of the result (224, 256, 384, or 512) |
DETAILS
SHA2()
is an encryption function that returns an SHA-2 checksum hash value for the string
argument.
The hash_length
number picks which hashing algorithm to use from the supported choices of 224, 256, 384, and 512 for the algorithms SHA-224, SHA-256, SHA-384, and SHA-512.
A hash_length
of 0 is also accepted and treated the same as a length argument of 256.
A NULL
is returned if the either argument is NULL
or the hash_length
is not one of the accepted values.
EXAMPLES
SELECT SHA2('abc', 224);
+----------------------------------------------------------+
| SHA2('abc', 224) |
+----------------------------------------------------------+
| 23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7 |
+----------------------------------------------------------+