Home  >  Article  >  Database  >  mysql encryption method

mysql encryption method

亚连
亚连Original
2018-05-10 10:28:142243browse

By encrypting the data in the Mysql database, we can make the database more secure, and the information and data inside will not be easily cracked.

MySQL has specially designed some functions to encrypt data. Here is a brief introduction to the following functions.

(1) AES_ENCRYPT and AES_DECRYPT functions

The syntax format is: aes_encrypt aes_decrypt(str,key)

The AES_ENCRYPT function returns The key key pair string str is encrypted using the Advanced Encryption Standard (AES) algorithm. The result is a binary string stored in the BLOB type. The AES_DECRYPT function is used to decrypt data encrypted with advanced encryption methods. If invalid data or incorrect padding is detected, the function returns NULL. The AES_ENCRYPT and AES_DECRYPT functions can be regarded as the most secure encryption functions commonly used in MySQL.

(2) ENCODE and DECODE functions

The syntax format is: encode |deCODE(str,key)

The ENCODE function is used to encode a character The string str is encrypted, and the returned result is a binary string stored in the BLOB type. The DECODE function decrypts the encrypted value using the correct key. Compared with the AES_ENCRYPT and AES_DECRYPT functions above, these two functions are relatively weak in encryption.

(3) ENCRYPT function

Use the UNIX crypt() system to encrypt a string. The encrypt(str, salt) function receives the string to be encrypted and is used for encryption. The salt of the process (a string that determines a unique password). Not available on Windows.

The above are the encryption functions that come with Mysql. I have briefly introduced a few. You can continue to add explanations in the comments below. . .

Related articles:

Related knowledge about PHP MySQL Order By keyword

How to read data through PHP MySQL

Related knowledge about PHP MySQL prepared statements

The above is the detailed content of mysql encryption method. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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
Previous article:Create an index for MyqlNext article:Create an index for Myql