Reputation: 5
Actually my problem is hash_password make a diffrent hash each time with same word i dont know how to check my input password with data base I have a hashed password in my db and im trying to hash my input with same algorythm but i get a diffrent value
$pass = password_hash($_post["pass"] , ARGON2I);
If($pass === $admin["Pass"]){
echo "success";
else
echo "failed";
Upvotes: 0
Views: 51
Reputation: 112875
Assuming the language is PHP:
password_hash
creates a unique hash each time even for the same password, this is because there is a random salt used each time. The salt is included in the result of password_hash
.
To verify the hashed password use password_verify
which uses the salt saved with the hash to compare and return a match or not.
The reason for the unique hashing is so that two users with the same password do not hash to the same value so that knowing one does not allow knowing other user's passwords from a matching hash.
See the linked documentation.
Upvotes: 2