Skip to content

Instantly share code, notes, and snippets.

@ss23
Created February 8, 2011 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ss23/815837 to your computer and use it in GitHub Desktop.
Save ss23/815837 to your computer and use it in GitHub Desktop.
<?php
$Password1 = 'WrongPassword';
$Password2 = 'SuperSecurePassword123';
$sql = "select `Password` from `Users` where id = 5";
$res = mysql_query($sql);
if ($res) {
$foo = mysql_fetch_assoc($res);
$HashedPassword = $foo['Password'];
} else {
die('error');
}
// Now, what about checking if a password is the right password?
if (crypt($Password1, $HashedPassword) == $HashedPassword) {
echo "Hashed Password matched Password1";
} else {
echo "Hashed Password didn't match Password1";
}
if (crypt($Password2, $HashedPassword) == $HashedPassword) {
echo "Hashed Password matched Password2";
} else {
echo "Hashed Password didn't match Password2";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment