Watch the 7.3 Webinar On-Demand
This new release brings updates to Universal Storage, query
optimization, and usability that you won’t want to miss.
Decrypts the given ciphertext using the AES (Advanced Encryption Standard) algorithm, with a 128-bit key.
AES_DECRYPT(ciphertext, key)
The plain text, or NULL if the key does not decrypt the ciphertext.
Note: the UNHEX function is used in this example to make it easier to handle binary data.
SELECT AES_DECRYPT(unhex('C958FF3BC0134ADE4A8F952338C1FAEC'), 'ohai');
+----------------------------------------------------------------+
| AES_DECRYPT(unhex('C958FF3BC0134ADE4A8F952338C1FAEC'), 'ohai') |
+----------------------------------------------------------------+
| secret message |
+----------------------------------------------------------------+
SELECT AES_DECRYPT(unhex('C958FF3BC0134ADE4A8F952338C1FAEC'), 'bad key');
+-------------------------------------------------------------------+
| AES_DECRYPT(unhex('C958FF3BC0134ADE4A8F952338C1FAEC'), 'bad key') |
+-------------------------------------------------------------------+
| NULL |
+-------------------------------------------------------------------+
Related Topics