MasterofProject
Subscribe cloud computing RSS CSDN home> cloud computing

MySQL database encryption and decryption

Published in14:49 2012-02-29| Time reading| sourceCodereflex.net| ZeroArticle comments| authorAsad Ahmed Syed

Abstract:Data encryption, decryption is very important in the field of security. For programmers, in the database to store user password encryption method is significant for the user to steal the user's privacy. There are a variety of front-end encryption algorithm can be used for data encryption, decryption, I recommend to you a simple database level of data encryption, decryption solution. In the table, the encrypted data is inserted into the MySQL database, and the corresponding encryption function is built...

Data encryption, decryption is very important in the field of security. For programmers, in the database to store user password encryption method is significant for the user to steal the user's privacy.

There are a variety of front-end encryption algorithm can be used for data encryption, decryption, I recommend to you a simple database level of data encryption, decryption solution.Taking the MySQL database as an example, the corresponding encryption functions (AES_ENCRYPT ()) and decryption functions (AES_DECRYPT) are built.

Insert the encrypted data in the table

  1. INSERT INTOUserData (username, pasword, encryptedpassword)
  2. VALUES('smith','htims'AES_ENCRYPT ('htims','key'))

The above insert statement has three fields, "username", "password", and "password" ". AES_ENCRYPT () function requires a "key" to assist the encryption, the same, decryption also need it (please keep in mind!).

The following is a table of data screenshot:

Query the encrypted data from the table

  1. SELECTUsername, pasword, AES_DECRYPT (encryptedpassword,'key')
  2. FROMUserData

The above query statement uses the AES_DECRYPT () function. The following is the result of the operation:

In the screenshot above, we can see that the value of "pasword" and "decryptedpassword" field is the same, that is to say, you have to decrypt the user password. (Zhang Zhiping / compile)

Text link:To Encrypt and Decrypt in How MySQL

top
Zero
step on
Zero
MySQL database encryption and decryption