MySQL database encryption and decryption:

Source: Internet
Author: User
Tags mysql database encryption
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:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.