Outdated Version
You are viewing an older version of this section. View current production version.
AES_DECRYPT
Decrypts the given ciphertext using the AES (Advanced Encryption Standard) algorithm, with a 128-bit key.
Syntax
AES_DECRYPT(ciphertext, key)
Arguments
- ciphertext: the binary data to decrypt
- key: the text or binary key to use for decryption
Return Type
The plain text, or NULL if the key does not decrypt the ciphertext.
Examples
Note: the UNHEX function is used in this example to make it easier to handle binary data.
memsql> select AES_DECRYPT(unhex('C958FF3BC0134ADE4A8F952338C1FAEC'), 'ohai');
+----------------------------------------------------------------+
| AES_DECRYPT(unhex('C958FF3BC0134ADE4A8F952338C1FAEC'), 'ohai') |
+----------------------------------------------------------------+
| secret message |
+----------------------------------------------------------------+
memsql> select AES_DECRYPT(unhex('C958FF3BC0134ADE4A8F952338C1FAEC'), 'bad key');
+-------------------------------------------------------------------+
| AES_DECRYPT(unhex('C958FF3BC0134ADE4A8F952338C1FAEC'), 'bad key') |
+-------------------------------------------------------------------+
| NULL |
+-------------------------------------------------------------------+
Related Topics