I have created a password using password_hash like so:
$password = password_hash('password123', PASSWORD_DEFAULT);
This is stored in a MySQL database in a column with varchar(60).
In my login form, I use:
if(password_verify($password, $foundUser->Password){
/*login*/
}
where $password
is the plaintext input from the login form and $foundUser->Password
is the hash that is stored in the database, but the password_verify()
function is always returning false.
I have checked my inputs using the following code:
echo "Password: {$password} <br>";
echo "Found password: ".$foundUser->Password."<br>";
which outputs:
Password: password123
Found password: $2y$10$8.ICQHCyCPzS.xygPO4cfuHsHZb6Kuxynn8/uUHOU1.7gY.UhSIXa
so I am reasonably confident I'm typing the right password in and getting the right hash from my database.
I have looked at the links in this question for answers but haven't made it work yet. Does anyone have any ideas why password_verify() is returning false?