Questions about MD5 password storage and comparison

Source: Internet
Author: User
I registered the password with MD5 encryption in the way of storage in MySQL, in the login with MD5 () comparison, the value has been wrong, resulting in a failure, to find answers


Reply to discussion (solution)

Put the code downstairs.

This is the function module of the judgment:
function PD () {//Verify the password is correct
$id =$_post[' id '];
$pwd =trim (MD5 ($_post[' pwd "));
echo "$pwd". "
";
$sql =mysql_query ("select * from ' xx ' WHERE ' id ' = ' $id ' and ' password ' = ' $pwd '");
$sql _p=mysql_num_rows ($sql);
echo "$sql _p";
if ($sql _p==0) {
echo "";
}
Else
{echo "";}
}

The MD5 value in the database;
Root2
E10adc3949ba59abbe56e057f20f88;
The value of the page display;
e10adc3949ba59abbe56e057f20f883e

$pwd =md5 (Trim ($_post[' pwd '));//If not, regenerate a MD5 value, put it in the database and try again, and see if it's wrong to insert it.

echo MD5 (' Root2 '); mysql_connect (); $rs = mysql_query ("Select MD5 (' Root2 ')");p Rint_r (Mysql_fetch_row ($rs));
9b70d6dbfb1457d05e4e2c2fbb42d7dbarray (    [0] = 9b70d6dbfb1457d05e4e2c2fbb42d7db)
There's no e10adc3949ba59abbe56e057f20f883e.

The page shows this e10adc3949ba59abbe56e057f20f883e
No, no, no, it's 123456, and you're root2.

PS again to say a word to look at you the database display is basically the number of bits that should be set in the password field is not reasonable caused by 2 characters less than char (32)

1.desc xx Look at the table structure, password field length requires 32 bits
2.

echo MD5 (' Root2 ');  9b70d6dbfb1457d05e4e2c2fbb42d7db


E10ADC3949BA59ABBE56E057F20F883E is the value of MD5 (123456).

The landlord can give the plaintext password, and the password recorded in the database.

  • Related Article

    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.