I'm using this tutorial to help me when salting and hashing users passwords when they create an account and then bringing those passwords back and comparing then when the user enters the password to log in.
In this tut they have two functions that I am suppose to call.
create_hash()
and
validate_hash()
I have subsequently created another function myself that explodes the resulted so I can strip the salted string from the entire has.
function explode_hash($password) {
return substr( $password, strrpos( $password, ':' ) + 1);
}
So when I am inserting the data in the database it looks like this
INSERT INTO `users` (`id`, `email`, `passwd`, `passwdhash`)
VALUES
(1,'email@email.com','sha256:1000:mvhkKCAoLgCHb2/Ie0muPIRH0YISriOr:+Ak9g9KV1BPMIRjUorx3/auhU5dgH0lS','+Ak9g9KV1BPMIRjUorx3/auhU5dgH0lS');
Note that the last column contains the last part of the string in the third column.
So the last step is when logging in the user will enter their email and password and my system will get the hash from the DB (based on the email) and run it through the function called
validate_hash()
But the result is always false.
Would anyone have a couple minutes to look over these steps and attempt to understand the reason I'm not able to get produce a proper comparison?