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.


DES_DECRYPT(encrypted_string, key_string);

Parameters Used:

  • encrypted_string – It is used to specify an encrypted string which is to be decrypted.
  • key_string – It is used to specify a key which is used to decrypt the encrypted string.

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

Supported Versions of MySQL:

  • MySQL 5.7
  • MySQL 5.6
  • MySQL 5.5
  • MySQL 5.1
  • MySQL 5.0
  • MySQL 4.1

Example-1: Implementing DES_DECRYPT function on a string.

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



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

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



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

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



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

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


My Personal Notes arrow_drop_up

I am a technology enthusiast who has a keen interest in programming I am pursuing Engineering in Computer Science from GEU, Dehradun I like to unwind by watching movies and English sitcomsI have a keen interest in music

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.