Encrypt, Decrypt password in Mysql

Some times you need to store encrypted data in the data base, specially for the case of user passwords.

Writing code to retrieve in programming language can be tedious. Mysql functions provide a great deal here.

You can easily encrypt fields when inserting in MySql

INSERT INTO PASSWORD(pass)
VALUES(DES_ENCRYPT(‘user password’));
This SQL will encrypt the user inserted field to a encrypted text.
Instead of DES_ENCRYPT() method you can come up with your own function also.

For retrieval you can use


SELECT DES_DECRYPT(pass) FROM PASSWORD ;
This SQL will return the encrypted text.

11 Responses to “Encrypt, Decrypt password in Mysql”

  1. better one but i require a md5 decryption …can u plz help me…
    i want to dispaly the decrypted password to the user when he/she forgots their password using md5 decryption..
    thank u ….

  2. this is the sintaxis man…!

    SELECT nombreUsuario FROM Usr
    WHERE passWord = DES_ENCRYPT(“JjjbHBSDS12DSklHJ”);

    from venezuela…!

  3. good quick writeup for DES Encryption

  4. This was relatively attention-grabbing to browse and scan your blog post, I did not know nothing about this before. Thanks alot : )!

  5. How are you ?,I all agree with your point,I may Sign up to your new blog page rss feed.

  6. Sikander Pal Thaper Says:

    rakhhhhhhh

  7. Oskar Graciano Says:

    Excelente Aportacion

  8. It will no work to decrypt to md5()…Is there any function for same?

  9. encryption and decryption data in mysql table for password.

  10. Gr8 Example Keep it up this is lot of help

  11. there is a tutorial sir ?

Leave a Reply

Spam Protection by WP-SpamFree

Einfobuzz Site Map