PHP has a variety of functions, among which the MD5 encryption function is one. Http://www.cenusblog.com "> in general, a website that provides member registration must collect the user password, how to save the user password is a problem. Of course, we cannot store passwords in plain text in the database, because in this case, the general administrator can view the user password, which is obviously quite dangerous for the user.
So how can we solve this problem? we can adopt such a strategy.
First, we will introduce how to use the MD5 function in PHP:
The code is as follows:
$ Pswd1 = md5 ("cenusdesign ");
Echo $ pswd1; // The running result is fc60ec37d1c08d5b0fb67a8cd934d5ba.
$ Pswd2 = md5 ("Cenusdesign ");
Echo $ pswd2; // The running result is 067577d9fc0000c80538c81d6f02bd293.
?>
Obviously, after md5 encryption, the original "cenusdesign" is converted into a 32-bit string, and even if the case of a letter changes, this string will undergo a huge change.
Cenus Design recommends that you first convert the password to MD5 upon registration, and then convert the encrypted database. When a user logs in, the password is first converted to MD5, and then compared with the MD5 encrypted strings in the database. In this way, the password comparison can be completed without knowing the user's exact password.
By Sunec
Original: http://www.cenusblog.com "target = _ blank> Cenus Blog
Copyright. The author and original source and this statement must be indicated in the form of links during reprinting.