Declaration
SM4_DECRYPT(str,key_str[,init_vector])
Description
Decodes the ciphertext str encrypted by SM4 using the key key_str to obtain the plaintext.
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 passed, the third value is 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,SM4_DECRYPTaccepts only 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