PHP & MySQL compare password

前端 未结 5 2135
滥情空心
滥情空心 2020-12-14 05:22

How does one check to see if a user has typed in the right password to log in?

This is what (out of a bunch of combinations...) I am doing:



        
5条回答
  •  情话喂你
    2020-12-14 06:13

    Greater than PHP 5.6, you can use hash_compare function.

     $users_password = hash(sha256,$salt.$post_password);
    
     if (hash_equals($users_dbpassword, $users_password)) {
          //pass is good
     } else {
           // pass failed
     }
    

    http://php.net/manual/ru/function.hash-equals.php

提交回复
热议问题