SHA224 Function

Overview

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

Syntax

sha224(expr)

Parameters

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

Return Result

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

Examples

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

    SELECT sha224('hello') AS res; +----------------------------------------------------------+ | res | +----------------------------------------------------------+ | ea09ae9cc6768c50fcee903ed054556e5bfc8347907f12598aa24193 | +----------------------------------------------------------+

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

    SELECT sha224('Hello, World!') AS res; +----------------------------------------------------------+ | res | +----------------------------------------------------------+ | 72a23dfa411ba6fde01dbfabf3b00a709c93ebf273dc29e2d8b261ff | +----------------------------------------------------------+

  3. When the input is NULL:

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

Notes

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