The MD5 function in PHP uses the instance code to _php the base

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.