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

Understand all aspects of HTTP Headers with pictures and text

What are HTTP Headers HTTP is an abbreviation of ...

Analysis of the Docker deployment Consul configuration process

Execute Command docker run -d --name consul -p 85...

JavaScript Closures Explained

Table of contents 1. What is a closure? 2. The ro...

Example of using CSS to achieve floating effect when mouse moves over card

principle Set a shadow on the element when hoveri...

Detailed explanation of Linux command file overwrite and file append

1. The difference between the command > and &g...

Summary of MySQL slow log practice

Slow log query function The main function of slow...

CSS style to center the HTML tag in the browser

CSS style: Copy code The code is as follows: <s...

HTML markup language - table tag

Click here to return to the 123WORDPRESS.COM HTML ...

Detailed explanation of SELINUX working principle

1. Introduction The main value that SELinux bring...

How to implement nested if method in nginx

Nginx does not support nested if statements, nor ...

VMware15.5 installation Ubuntu20.04 graphic tutorial

1. Preparation before installation 1. Download th...

Example code for implementing the "plus sign" effect with CSS

To achieve the plus sign effect shown below: To a...