How to compare user input with db password when using PHP's sha256 hash method? -
say set new users password this:
$salt = random_string(40) // method spits out random // 40 alpha-numeric character string $password = hash('sha256', $_post['password'] . $salt);
how compare users input hashed db password when wants log in?
at login time,
- fetch password hash , salt stored in database @ registration time (using account name, or email-address)
- hash provided password same method , same salt
- compare hash hash stored. if same, password matches.
the key here store salt.
Comments
Post a Comment