DES_DECRYPT( )

This MySQL function decrypts text that was encrypted using the triple DES algorithm with a 128-bit key length, reversing the DES_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).

DES_DECRYPT(string, [key])

Explanation

This function decrypts text that was encrypted using the triple DES algorithm with a 128-bit key length, reversing the DES_ENCRYPT() function. It returns NULL if an error occurs. The function will work only if MySQL has been configured for secure sockets layer (SSL) support. It is available as of version 4.0.1 of MySQL.

Examples

SELECT DES_DECRYPT(credit_card_nbr, 0)
FROM orders
WHERE order_nbr = '8347';

In this example, the value for the credit_card_nbr column is decrypted using the first key string in the key file. See the description of DES_ENCRYPT( ) for more information on key files.