MySQL database encryption and decryption:
Data encryption and decryption are important in the area of security. For programmers, storing user passwords in a database with ciphertext is significant for intruders to steal users ' privacy.
There are a variety of front-end encryption algorithms can be used for data encryption, decryption, below I recommend a simple database-level data encryption, decryption solution. In the case of MySQL database, it built the corresponding cryptographic function (Aes_encrypt ()) and decryption function (Aes_decrypt ()).
When building a table, be aware of the type of the field. As shown in:
Inserting encrypted data into a table
The INSERT statement above has three fields, user name, password, and encrypted password. The Aes_encrypt () function requires a "key" to aid in encryption, and the decryption also requires it (keep in mind!). )。
The following is the data in the table:
The INSERT statement above has three fields, user name, password, and encrypted password. The Aes_encrypt () function requires a "key" to aid in encryption, and the decryption also requires it (keep in mind!). )。
The following is the data in the table:
Querying encrypted data from a table
The above query statement uses the Aes_decrypt () function. Here is the result of the operation:
In the above, we can see that the values of the "Pasword" and "Decryptedpassword" fields are the same, that is, you have decrypted the user's password.
Reprint Please specify source: http://blog.csdn.net/johnny901114/article/details/7739008
MySQL database encryption and decryption: