我尝试了如何使用 bcrypt 在 PHP 中散列密码? 但似乎无法获得一个有效的例子。我复制了 Bcrypt 类并在其底部添加了以下代码。
$bcrypt = new Bcrypt(15);
// pw on server. Used $pwHash = $bcrypt->hash($formPassword); to get the hash from 'qwerty'.
$serverPw = '$2a$15$Ty6hIEEWFpUFHoKujvdmw.9kmyrwYip2s8TLdjDfNoVJuQx/TGgwu';
// user enters plain text pw...
$passAttempt = 'qwerty';
// attempt to check the attempted password against the server hashed pasword.
$pwVerify = $bcrypt->verify($serverPw, $passAttempt);
if ( $pwVerify == 1 ) {echo "$pwVerify = true";} else {echo "$pwVerify = not true";}
// I also tried if ($pwVerify) and if ($bcrypt->verify($serverPw, $passAttempt))
// Output is "= not true"
这里有什么问题?