MySQL encryption and decryption examples

MySQL encryption and decryption examples

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. Here I recommend a simple database-level data encryption and decryption solution. Taking the MySQL database as an example, it has built-in corresponding encryption functions (AES_ENCRYPT()) and decryption functions (AES_DECRYPT()).

When building a table, pay attention to the type of field. As shown in the following figure:

Insert encrypted data into the table

The above insert statement has three fields, "Username", "Password" and "Encrypted Password". The AES_ENCRYPT() function requires a "key" to assist with encryption, and it is also required for decryption (remember this!).

The following is a screenshot of the data in the table:

The above insert statement has three fields, "Username", "Password" and "Encrypted Password". The AES_ENCRYPT() function requires a "key" to assist with encryption, and it is also required for decryption (remember this!).

The following is a screenshot of the data in the table:

Query encrypted data from the table

The query above uses the AES_DECRYPT() function. Here are the results:

In the above screenshot, we can see that the values ​​of the "pasword" and "decryptedpassword" fields are the same, that is, you have decrypted the user password.

Thank you for reading, I hope it can help you, thank you for your support of this site!

You may also be interested in:
  • Sharing of MD5 encryption algorithm implemented in Java, JavaScript, Oracle, and MySQL
  • MD5 encryption statement for mysql and mssql
  • Using XOR encryption algorithm in PHP MySQL application
  • MySQL encryption/compression functions
  • Detailed explanation of MySQL two-way encryption and decryption usage
  • MySQL whole table encryption solution keyring_file detailed explanation

<<:  Share 12 commonly used Loaders in Webpack (Summary)

>>:  How to upload the jar package to nexus via the web page

Recommend

How to install MySQL and MariaDB in Docker

Relationship between MySQL and MariaDB MariaDB da...

Mysql get table comment field operation

I won't say much nonsense, let's just loo...

Detailed steps for remote deployment of MySQL database on Linux

Linux remote deployment of MySQL database, for yo...

Install ethereum/Ethereum from scratch under CentOS7

Table of contents Preface Add sudo write permissi...

WeChat applet realizes multi-line text scrolling effect

This article example shares the specific code for...

In-depth understanding of MySQL global locks and table locks

Preface According to the scope of locking, locks ...

mysql5.7.17.msi installation graphic tutorial

mysql-5.7.17.msi installation, follow the screens...

Simple implementation of Mysql add, delete, modify and query statements

Simple implementation of Mysql add, delete, modif...

9 Tips for Web Page Layout

<br />Related articles: 9 practical suggesti...

Detailed explanation of the WeChat applet request pre-processing method

question Because some of our pages request data i...

Vue implements verification code countdown button

This article example shares the specific code of ...

Learn MySQL index pushdown in five minutes

Table of contents Preface What is index pushdown?...

jQuery realizes the shuttle box function

This article example shares the specific code of ...

How to configure pseudo-static and client-adaptive Nginx

The backend uses the thinkphp3.2.3 framework. If ...