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. For more information, see tde_method.You must have the
DECRYPTprivilege to use this function.cipher_textspecifies the ciphertext to be decrypted.[, iv]is an optional parameter that specifies the initialization vector.The
ENHANCED_AES_DECRYPTfunction can be used only to decrypt ciphertext generated by theENHANCED_AES_ENCRYPTfunction. Otherwise, the function returns an error of theOB_ERR_AES_DECRYPTtype.
Examples
The following example shows how to use the ENHANCED_AES_DECRYPT function to return the plaintext of a column.
-- Return the plaintext.
SELECT ENHANCED_AES_DECRYPT(cipher_col) FROM tbl;
You can compare the ciphertext with the plaintext directly. However, the comparison returns false. To compare the ciphertext with the plaintext, you must decrypt the ciphertext or encrypt the plaintext.
-- Decrypt the ciphertext in the cipher_col column and compare it with the plaintext data '12345'. However, you cannot use an index for this comparison.
SELECT ... FROM tbl WHERE ENHANCED_AES_DECRYPT(cipher_col) = '12345';
