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

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

This SQL will return the encrypted text.

DES Encryption and Decryption Java

The Data Encryption Standard (DES) is a block cipher (a method for encrypting information) that was selected by NBS as an official Federal Information Processing Standard (FIPS) for the United States in 1976 and which has subsequently enjoyed widespread use internationally. It is based on a Symmetric-key algorithm that uses a 56-bit key. The algorithm was initially controversial with classified design elements, a relatively short key length, and suspicions about a National Security Agency (NSA) backdoor. DES consequently came under intense academic scrutiny which motivated the modern understanding of block ciphers and their cryptanalysis. Read full story »

Einfobuzz Site Map