Syntax
ENHANCED_AES_DECRYPT(cipher_text[, iv])
Purpose
The
ENHANCED_AES_DECRYPTfunction is used to decrypt data using the AES algorithm. This feature is controlled by thetde_methodparameter. For more information, see tde_method.The
ENHANCED_AES_DECRYPTfunction requires theDECRYPTprivilege.The
cipher_textparameter specifies the ciphertext to be decrypted.The
[, iv]parameter is optional and specifies the initialization vector.The
ENHANCED_AES_DECRYPTfunction must be used with theENHANCED_AES_ENCRYPTfunction to decrypt data. Otherwise, an error will occur.
Examples
Use the ENHANCED_AES_DECRYPT function to return the plaintext column in a SELECT statement.
-- Return the plaintext.
SELECT ENHANCED_AES_DECRYPT(cipher_col) FROM tbl;
You cannot directly compare ciphertext with plaintext. You must decrypt the ciphertext or encrypt the plaintext before comparison.
-- Decrypt the cipher_col and match the corresponding plaintext data '12345'. However, you cannot use the index.
SELECT ... FROM tbl WHERE ENHANCED_AES_DECRYPT(cipher_col) = '12345';