SM3 Function
Overview
The SM3 function computes the SM3 hash value for a given string. SM3 is a cryptographic hash function standard (GB/T 32905-2016) issued by the State Cryptography Administration of China, capable of mapping arbitrary-length data to a fixed-length (256-bit) hash value, outputting a 64-character hexadecimal string.
Syntax
sm3(expr)
Parameters
expr: The input data for which to compute the SM3 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 SM3 value of a simple string:
-
Compute the SM3 value of a numeric string:
-
When the input is NULL:
Notes
- SM3 is a commercial cryptographic hash algorithm standard (GB/T 32905-2016) issued by the State Cryptography Administration of China, belonging to the Chinese national cryptographic algorithm suite.
- SM3 hash values are irreversible, meaning the original data cannot be derived from the hash value.
- SM3 outputs a fixed 64-character hexadecimal string (256 bits).
- When the input parameter is NULL, the result is NULL.
- SM3 offers security comparable to SHA-256, suitable for data integrity verification, digital signatures, and other scenarios.
