The MD5 function in PHP uses the instance code. Generally, a website that provides member registration must collect the user's password. how to save the user password is a problem. We certainly cannot store passwords in plain text. generally, a website that provides member registration must collect user passwords. how to save user passwords 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:
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.
The above is the content of the instance code used by the MD5 function in PHP. For more information, see PHP Chinese network (www.php1.cn )!