AES_DECRYPT( )

This MySQL function decrypts text that was encrypted using the AES algorithm with a 128-bit key length, reversing the AES_ENCRYPT() function.

Syntax

Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

AES_DECRYPT(string, password)

Explanation

This function decrypts text that was encrypted using the AES algorithm with a 128-bit key length, reversing the AES_ENCRYPT() function. The function unlocks the encrypted string with the password given as the second argument. It returns NULL if one of the given parameters is NULL. This is available as of version 4.0.2 of MySQL.

Examples

SELECT AES_DECRYPT(personal, 'my_password') AS Personal
FROM teachers
WHERE teacher_id='730522';

+----------+
| Personal |
+----------+
| text     |
+----------+

In this example, the value for the personal column is decrypted using the password given. The result is just the plain text of the password.