SHA2

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.

Syntax

SHA2 ( plaintext, bitlen )

Arguments

  • plaintext: the data to hash.

  • bitlen: the size of the hash to create. Currently SingleStore 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 |
+----------------------------------------------------------------------------------------------------------------------------------+

Last modified: February 27, 2023

Was this article helpful?

Verification instructions

Note: You must install cosign to verify the authenticity of the SingleStore file.

Use the following steps to verify the authenticity of singlestoredb-server, singlestoredb-toolbox, singlestoredb-studio, and singlestore-client SingleStore files that have been downloaded.

You may perform the following steps on any computer that can run cosign, such as the main deployment host of the cluster.

  1. (Optional) Run the following command to view the associated signature files.

    curl undefined
  2. Download the signature file from the SingleStore release server.

    • Option 1: Click the Download Signature button next to the SingleStore file.

    • Option 2: Copy and paste the following URL into the address bar of your browser and save the signature file.

    • Option 3: Run the following command to download the signature file.

      curl -O undefined
  3. After the signature file has been downloaded, run the following command to verify the authenticity of the SingleStore file.

    echo -n undefined |
    cosign verify-blob --certificate-oidc-issuer https://oidc.eks.us-east-1.amazonaws.com/id/CCDCDBA1379A5596AB5B2E46DCA385BC \
    --certificate-identity https://kubernetes.io/namespaces/freya-production/serviceaccounts/job-worker \
    --bundle undefined \
    --new-bundle-format -
    Verified OK