In general, a member to provide registration of the site must collect the user's password, how to save the user password is a problem. We certainly cannot store passwords in plaintext in the database, because in this way, the average administrator can see the user's password, which is obviously a very dangerous thing for the user.
How to solve this problem, we can take such a strategy.
First introduce the use of the MD5 function in PHP:
Copy the Code code as follows:
<?php $pswd 1=md5 ("cenusdesign"); echo $pswd 1; The result of operation is: Fc60ec37d1c08d5b0fb67a8cd934d5ba $pswd 2=md5 ("cenusdesign"); echo $pswd 2; Operation Result: 067577d9fc109c80538c81d6f02bd293 ?>
Obviously, after MD5 encryption, the original "Cenusdesign" is transformed into a set of 32-bit strings, and even if the case of a letter changes, this set of strings will change dramatically.
Cenus Design recommends that when the user registers, the password is converted first through MD5, and then the encrypted database is converted. When the user logs on, the password is MD5 converted, and then compared with the set of MD5 encrypted strings in the database. This makes it possible to do a password-specific operation without knowing the user's exact password.
The above is the PHP MD5 function Use instance code content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!