SHA384 Function

Overview

The SHA384 function computes the SHA-384 hash value for a given string. SHA-384 is a variant of the SHA-2 family of hash algorithms that can map arbitrary-length data to a fixed-length (384-bit) hash value, outputting a 96-character hexadecimal string.

Syntax

sha384(expr)

Parameters

  • expr: The input data for which to compute the SHA-384 hash value. Supports STRING, VARCHAR, CHAR, and BINARY types.

Return Result

Returns a STRING type value representing the computed 96-character hexadecimal hash string.

Examples

  1. Compute the SHA-384 value of a simple string:

    SELECT sha384('hello') AS res; +--------------------------------------------------------------------------------------------------+ | res | +--------------------------------------------------------------------------------------------------+ | 59e1748777448c69de6b800d7a33bbfb9ff1b463e44354c3553bcdb9c666fa90125a3c79f90397bdf5f6a13de828684f | +--------------------------------------------------------------------------------------------------+

  2. Compute the SHA-384 value of a string containing special characters:

    SELECT sha384('Hello, World!') AS res; +--------------------------------------------------------------------------------------------------+ | res | +--------------------------------------------------------------------------------------------------+ | 5485cc9b3365b4305dfb4e8337e0a598a574f8242bf17289e0dd6c20a3cd44a089de16ab4ab308f63e44b1170eb5f515 | +--------------------------------------------------------------------------------------------------+

  3. When the input is NULL:

    SELECT sha384(NULL) AS res; +------+ | res | +------+ | NULL | +------+

Notes

  • SHA-384 hash values are irreversible, meaning the original data cannot be derived from the hash value.
  • SHA-384 outputs a fixed 96-character hexadecimal string (384 bits).
  • When the input parameter is NULL, the result is NULL.
  • SHA-384 belongs to the SHA-2 family of algorithms, offering higher security than SHA-256, suitable for data integrity verification, digital signatures, and other scenarios requiring higher security.