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,

  1. fetch password hash , salt stored in database @ registration time (using account name, or email-address)
  2. hash provided password same method , same salt
  3. compare hash hash stored. if same, password matches.

the key here store salt.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -