Notice
Community Edition does not support the `sm4_decrypt` system function.
Syntax
SM4_DECRYPT(str,key_str[,init_vector])
Purpose
Returns the plaintext of the ciphertext str after SM4 decryption using the key key_str.
For more information about the init_vector parameter, see SM4_ENCRYPT.
Examples
- In
sm4-ecbmode, theSM4_DECRYPTfunction accepts two parameters{str, key_str}. If three values are provided, the third value will be ignored. For example:
SET block_encryption_mode = 'sm4-ecb';
SELECT hex(sm4_decrypt('asdasdasdasd', '12312313123')) FROM dual;
+-------------------------------------------------+
| hex(sm4_decrypt('asdasdasdasd', '12312313123')) |
+-------------------------------------------------+
| NULL |
+-------------------------------------------------+
1 row in set
- In
sm4-cbc,sm4-cfb, andsm4-ofbmodes, theSM4_DECRYPTfunction accepts three parameters. For example:
SET block_encryption_mode= 'sm4-cbc';
SELECT hex(sm4_decrypt('asdasdasdasd', '12312313123', 'asdasdkljasdkljalskdjaklsdjaklsjdaklsdjlaksdj')) FROM dual;
+--------------------------------------------------------------------------------------------------+
| hex(sm4_decrypt('asdasdasdasd', '12312313123', 'asdasdkljasdkljalskdjaklsdjaklsjdaklsdjlaksdj')) |
+--------------------------------------------------------------------------------------------------+
| NULL |
+--------------------------------------------------------------------------------------------------+
1 row in set
