Notice
OceanBase Database Community Edition does not support the SM4_DECRYPT system function.
Syntax
SM4_DECRYPT(str,key_str[,init_vector])
Purpose
AES_DECRYPT() returns the plaintext obtained by decrypting the ciphertext specified by str by using the key specified by key_str and the SM4 algorithm.
For more information about the init_vector parameter, see SM4_ENCRYPT.
Examples
In
sm4-ecbmode,SM4_DECRYPT()accepts two arguments{str, key_str}. If three values are passed in, the third value is ignored. Here is an example:SET block_encryption_mode = 'sm4-ecb'; SELECT hex(sm4_decrypt('asdasdasdasd', '12312313123')) FROM dual; +-------------------------------------------------+ | hex(sm4_decrypt('asdasdasdasd', '12312313123')) | +-------------------------------------------------+ | NULL | +-------------------------------------------------+ 1 row in setIn
sm4-cbc,sm4-cfb, andsm4-ofbmodes,SM4_DECRYPT()accepts only three arguments. Here is an 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