Open In App

MySQL | DES_DECRYPT ( ) Function

The MySQL DES_DECRYPT function is used for decrypting an encrypted string using DES(Data Encryption Standard) algorithm. The MySQL DES_DECRYPT function uses a key to decrypt a string.

The value returned by the DES_DECRYPT function is a decrypted string or NULL. The DES_DECRYPT function accepts two parameters which are the encrypted string and a key string to decrypt the string.



Syntax:

DES_DECRYPT(encrypted_string, key_string);

Parameters Used:



Return Value:
The DES_DECRYPT function in MySQL returns a decrypted string.

Supported Versions of MySQL:

Example-1: Implementing DES_DECRYPT function on a string.

SELECT  
AES_DECRYPT(AES_ENCRYPT('ABC', 'key_string'), 'key_string'); 

Output:

ABC 

Example-2: Implementing AES_DECRYPT function on a string with a combination of characters and integer values.

SELECT  
AES_DECRYPT(AES_ENCRYPT('ABC123', 'key_string'), 'key_string'); 

Output:

ABC123 

Example-3: Implementing AES_DECRYPT function on a bigger string.

SELECT  
AES_DECRYPT(AES_ENCRYPT('Geeksforgeeks', 'key_string'), 'key_string'); 

Output:

Geeksforgeeks 

Example-4: Implementing AES_DECRYPT function on a NULL string.

SELECT  
AES_DECRYPT(AES_ENCRYPT(NULL, 'key_string'), 'key_string'); 

Output:

NULL 
Article Tags :
SQL