I have this hashed password with a random generated salt, and I’m trying to figure out how I can possibly compare a password entered into a login form with an existing crypt password. Here’s the formula I’m using to enter the password when creating a user:
$salt = mt_rand();
$hashedPassword = crypt($password, '$6$rounds=5000$'.$salt);
How can I compare two hashed password (one from the database and one from the login form) to see if they match?
You have to know what the salt is for that particular user – so be sure you’re saving the salt. Then just add the salt to the user entered password and encrypt that and compare those together.