Watch the 7.3 Webinar On-Demand
This new release brings updates to Universal Storage, query
optimization, and usability that you won’t want to miss.
Hashes the given string or binary data using the secure hash algorithm, version 2. As of this writing (early 2015), SHA2 is considered secure for generating collision-resistant hashes.
SHA2 ( plaintext, bitlen )
Lower case hexadecimal digits corresponding to the binary hash value.
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 |
+----------------------------------------------------------------------------------------------------------------------------------+