This article mainly introduces the relevant information of MySQLEncryption and decryption examples, friends in need can refer to
MySQL encryption and decryption examples
Data encryption and decryption are very important in the security field. For programmers, storing user passwords in ciphertext in the database is of great significance to intruders who steal user privacy.
There are a variety of front-end encryption algorithms that can be used for data encryption and decryption. Below I recommend a simple database-level data encryption and decryption solution to you. Taking MySQL database as an example, it has built-in corresponding encryption function (AES_ENCRYPT()) and decryption function (AES_DECRYPT()).
When creating a table, pay attention to the field types. As shown in the figure below:
Insert encrypted data into the table
The above insert statement has three fields, "user name", " Password" and "Encrypted Password". The AES_ENCRYPT() function requires a "key" to assist in encryption, and it is also required for decryption (remember this!).
The following is a screenshot of 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 assist in encryption, and it is also required for decryption (remember this!).
The following is a screenshot of the data in the table:
Query from the tableEncrypted data
The above query statement uses the AES_DECRYPT() function. The following is the running result:The above is the detailed content of Detailed explanation of encryption and decryption examples in MySQL. For more information, please follow other related articles on the PHP Chinese website!