SHA256 Function
Overview
The SHA256 function computes the SHA-256 hash value for a given string. SHA-256 is the most commonly used variant of the SHA-2 family of hash algorithms, capable of mapping arbitrary-length data to a fixed-length (256-bit) hash value, outputting a 64-character hexadecimal string.
Syntax
sha256(expr)
Parameters
expr: The input data for which to compute the SHA-256 hash value. Supports STRING, VARCHAR, CHAR, and BINARY types.
Return Result
Returns a STRING type value representing the computed 64-character hexadecimal hash string.
Examples
-
Compute the SHA-256 value of a simple string:
-
Compute the SHA-256 value of a string containing special characters:
-
When the input is NULL:
Notes
- SHA-256 hash values are irreversible, meaning the original data cannot be derived from the hash value.
- SHA-256 outputs a fixed 64-character hexadecimal string (256 bits).
- When the input parameter is NULL, the result is NULL.
- SHA-256 belongs to the SHA-2 family of algorithms and is one of the most widely used secure hash algorithms today, suitable for data integrity verification, digital signatures, and other scenarios.
