Important
New database features are no longer connected to engine versions; features are now enabled independently during scheduled update windows, and “major” and “minor” releases no longer exist in Helios. Please visit the release notes to view the latest features available in your database clusters.
SHA2
On this page
The SHA2() function hashes the given string or binary data using the secure hash algorithm, version 2.
Syntax
SHA2 ( plaintext, bitlen )
Arguments
-
plaintext: the data to hash.
-
bitlen: the size of the hash to create.
Currently SingleStore Helios supports only the values 256, 384, 512, and 0 (equivalent to 256).
Return Type
Lower case hexadecimal digits corresponding to the binary hash value.
Examples
SELECT SHA2('ohai', 0);
+------------------------------------------------------------------+
| SHA2('ohai', 0) |
+------------------------------------------------------------------+
| e84712238709398f6d349dc2250b0efca4b72d8c2bfb7b74339d30ba94056b14 |
+------------------------------------------------------------------+SELECT SHA2('ohai', 256);
+------------------------------------------------------------------+
| SHA2('ohai', 256) |
+------------------------------------------------------------------+
| e84712238709398f6d349dc2250b0efca4b72d8c2bfb7b74339d30ba94056b14 |
+------------------------------------------------------------------+SELECT SHA2('ohai', 384);
+--------------------------------------------------------------------------------------------------+
| SHA2('ohai', 384) |
+--------------------------------------------------------------------------------------------------+
| 2e2f6fcb70ea17cb674d7ba268026e30bde4cbe7abd74adc80d47f56ab15a5cc3e4e11e661cc22075a5b3b111bcc9afb |
+--------------------------------------------------------------------------------------------------+SELECT SHA2('ohai', 512);
+----------------------------------------------------------------------------------------------------------------------------------+
| SHA2('ohai', 512) |
+----------------------------------------------------------------------------------------------------------------------------------+
| c8bd85242ad59306e2f5cd0f26c44408bf4e9a7c6b6f3f8317fd226bd131435400eff8de7b5f9927ea4aa4c0624cdd3a23630b1b5ab76207adae442e019284e5 |
+----------------------------------------------------------------------------------------------------------------------------------+Related Topics
Last modified: