Home > Database > Mysql Tutorial > Detailed explanation of MySQL password encryption and decryption

Detailed explanation of MySQL password encryption and decryption

藏色散人
Release: 2020-04-16 11:37:08
forward
5003 people have browsed it

MySQL password encryption and decryption detailed explanation

There are a variety of front-end encryption algorithms that can be used for data encryption and decryption. This is a simple database-level data encryption and decryption solution.

Take the MySQL database as an example. It has built-in corresponding encryption function (AES_ENCRYPT()) and decryption function (AES_DECRYPT()).

1. Create a table: Pay attention to the type of data when building a table

CREATE TABLE users( username VARCHAR(10), PASSWORD VARCHAR(10), testpswd VARBINARY(20) );
Copy after login

This table has three fields, 'username', 'password', 'encrypted password' '.

2. Insert data into the table

INSERT INTO users (username,PASSWORD,testpswd) VALUES ('sxyu','1233210',AES_ENCRYPT('1233210','key'));
Copy after login

Insert a record. The AES_ENCRYPT() function requires a "key" to assist encryption and decryption. It is also required. keep in mind.

3. Query the encrypted data (decryption) from the table:

SELECT username,PASSWORD,AES_DECRYPT(testpswd,'key') FROM users
Copy after login

It can be found from the query results that the decrypted password is the same as the original password.

Recommended: "mysql video tutorial"

The above is the detailed content of Detailed explanation of MySQL password encryption and decryption. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template