[英]How to use bcrypt with php for password authentication?
我嘗試了如何在PHP中使用bcrypt進行散列密碼的頂級解決方案帖子? 但似乎無法得到一個工作的例子。 我復制了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"
這有什么不對?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.