All pages
Powered by GitBook
1 of 1

Loading...

AES_DECRYPT

Decrypt data using AES. This function decrypts a string that was encrypted using the Advanced Encryption Standard (AES) algorithm.

Syntax

AES_ENCRYPT(crypt_str, key_str, [, iv [, mode]])
AES_DECRYPT(crypt_str,key_str)

Description

This function allows decryption of data using the official AES (Advanced Encryption Standard) algorithm. For more information, see the description of .

The function supports an initialization vector, and control of the block encryption mode. The default mode is specified by the system variable, which can be changed when calling the function with a mode. mode is aes-{128,192,256}-{ecb,cbc,ctr} for example: "AES-128-cbc".

For modes that require it, the initialization_vector iv should be 16 bytes (it can be longer, but the extra bytes are ignored). A shorter iv, where one is required, results in the function returning NULL. Calling will generate a random series of bytes that can be used for the iv.

Examples

The function does not support an initialization vector.

This page is licensed: GPLv2, originally from

AES_ENCRYPT()
block_encryption_mode
RANDOM_BYTES(16)
fill_help_tables.sql
SELECT HEX(AES_ENCRYPT('foo', 'bar', '0123456789abcdef', 'aes-128-ctr')) AS x; 
+--------+
| x      |
+--------+
| C57C4B |
+--------+


SELECT AES_DECRYPT(x'C57C4B', 'bar', '0123456789abcdef', 'aes-128-ctr'); 
+------------------------------------------------------------------+
| AES_DECRYPT(x'C57C4B', 'bar', '0123456789abcdef', 'aes-128-ctr') |
+------------------------------------------------------------------+
| foo                                                              |
+------------------------------------------------------------------+