Home  >  Article  >  Database  >  How MySQL uses encryption functions

How MySQL uses encryption functions

PHPz
PHPzforward
2023-05-28 08:09:331863browse

Encryption function

Command: md5(data)

Function: used to encrypt data

Application scenarios: encryption, some private data, For example, bank card numbers, ID cards, etc. need to store ciphertext. (Of course, it is not recommended to use database layer encryption. It should be encrypted at the application layer.)

Example:

mysql> select md5("andyqian");
+----------------------------------+
| md5("andyqian")   |
+----------------------------------+
| 8a6f60827608e7f1ae29d1abcecffc3a |
+----------------------------------+
1 row in set (0.00 sec)

Note: If your database currently The data in is still plain text, and you can use the database encryption algorithm to encrypt it.

For example: (for demonstration only):

update t_base_user set name=md5(name),updated_time=now() where id=1;

Supported encryption functions are:

md5()
des_encrypt(加密) / des_decrypt(解密);
sha1()
password() 等等

The above is the detailed content of How MySQL uses encryption functions. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete