Syntax
ENHANCED_AES_DECRYPT(cipher_text[, iv])
Purpose
This function is mainly used for column encryption. To enable column encryption, set the
tde_methodparameter toENHANCED_AES_DECRYPT. For more information, see tde_method.This function requires the
DECRYPTprivilege.cipher_textspecifies the ciphertext to be decrypted.[, iv]is an optional parameter that specifies the initialization vector.The
ENHANCED_AES_DECRYPTfunction requires that thecipher_textparameter be the result of theENHANCED_AES_DECRYPTfunction. Otherwise, an error ofOB_ERR_AES_DECRYPTis returned.
Examples
Use the ENHANCED_AES_DECRYPT function in a SELECT statement to return the plaintext of a column.
-- Return plaintext
SELECT ENHANCED_AES_DECRYPT(cipher_col) FROM tbl;
You can directly compare the ciphertext with the corresponding plaintext. However, the comparison returns false. To compare them, you must decrypt the ciphertext or encrypt the plaintext.
-- Decrypt the ciphertext in the cipher_col column and match it with the plaintext data '12345'. However, you cannot use an index.
SELECT ... FROM tbl WHERE ENHANCED_AES_DECRYPT(cipher_col) = '12345';