亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如果密碼包含在要解析的字符串中,Password_verify() 給出 true

如果密碼包含在要解析的字符串中,Password_verify() 給出 true

PHP
狐的傳說 2023-08-19 16:45:46
幾天來我遇到了一個關于password_verify()的問題。在我的網址中輸入密碼失敗之前我沒有注意到這一點。解釋一下,我正在開發一個 Web 服務,為了進行身份驗證,我需要在請求 URL 中使用密碼和 ID。這是我的代碼 if ($stmt->prepare("SELECT hashedPWD FROM `user` WHERE `id` = ?")){ // Trying to get the hashed pwd stored in DB            $stmt->bind_param("i", $id);            $stmt->execute();            $stmt->bind_result($pwdHash); // $pwdHash contains the password hashed by password_hash() when the account was created            $stmt->fetch();            $stmt->close();        }$password = "test"; // The password in URL which is the good one$isPwdGood = password_verify($password, $pwdHash);var_dump($isPwdGood); // returns true, seems good right there$password = "testtttttttttt"; // contains the real password with some others characters  $isPwdGood = password_verify($password, $pwdHash);var_dump($isPwdGood); // returns also true這里的問題是,當我想確認我的客戶的身份時,我需要確保密碼是他給我的密碼,但是使用password_verify()我可以獲得一個包含真實密碼的錯誤密碼,并且它會起作用。
查看完整描述

1 回答

?
慕哥6287543

TA貢獻1831條經驗 獲得超10個贊

我沒有觀看創建帳戶的整個過程,應該這樣做,因為我剛剛看到使用的函數是 crypt() 并且(我不知道為什么)它與以前的鹽和哈希值配合得不好密碼。

我嘗試切換到我向您展示的函數,即password_hash(),它效果更好!

查看完整回答
反對 回復 2023-08-19
  • 1 回答
  • 0 關注
  • 123 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號