简体   繁体   中英

Same Hash value on different input

I have got this html form:

 <form action="seite2.php" method="post"> Benutzername:<br /> <input type="Text" name="username"><br /><br /> Passwort:<br /> <input type="Password" name="passwort" /> <input type="Submit" value="Absenden" /> </form> 

on seite2.php I have got this code first, to check the Hash value:

$username = $_POST["username"];
$passwort = $_POST["passwort"];

$pass = sha1($passwort);

echo $pass;

then, I want to check wether username&&password is correct and compare the hashs. Lets say username is: mue. and password is: pass. I get this hash: da39a3ee5e6b4b0d3255bfef95601890afd80709.

if($username == "mue" AND $pass=="da39a3ee5e6b4b0d3255bfef95601890afd80709")
{
    echo '<p>';
    echo "Herzlich Willkommen";
    echo '</p>';
}
else
{
    echo '<p>';
    echo "Login failed";
    echo '</p>';

But in my Browser, I get following response: da39a3ee5e6b4b0d3255bfef95601890afd80709 Login failed.

And no matter which user or password I'll take, the hash given back from the browser is always the same.

The code is ok,i try it and work but the sha1 of "pass" is:

   9d4e1e23bd5b727046a9e3b4b7db57bd8d6ee684

maybe you modify the worse file. see your editor and see if you change the right "seite2.php". if you change the path location of this file maybe the old file remained in the IDE and you edit this one and no the new one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM