Generally speaking, a website that provides the member registration must collect the user's password, how to save the user's password is a problem. Of course we can't store passwords in the database in plaintext, because in this case, the general administrator can see the user's password, obviously for the user is a very dangerous thing.
So how to solve this problem, we can take such a strategy.
First, introduce the use of MD5 functions in PHP:
Copy Code code as follows:
<?php
$PSWD 1=md5 ("cenusdesign");
echo $PSWD 1; The results of the operation are: FC60EC37D1C08D5B0FB67A8CD934D5BA
$PSWD 2=md5 ("cenusdesign");
echo $PSWD 2; The results of the operation are: 067577d9fc109c80538c81d6f02bd293
?>
Obviously, after MD5 encryption, the original "Cenusdesign" into a set of 32-bit string, and, even if the case of a letter, the set of strings will change dramatically.
Cenus Design recommends that when registering a user, the password is converted first through MD5, and then the encrypted database is converted. When the user logs in, the password is MD5 converted first, and then compared with the set of MD5 encrypted strings in the database. In this way, you can do without knowing the exact password of the user to complete the operation of the password.
Author: Sunec
Original download: Cenus Blog
All rights reserved. Reprint must be linked to the form of the author and the original source and this statement.