Bug #80297 [Com]: password_verify won't work with double quotes
| From: | rtrtrtrtrt at dfdfdfdf dot dfd | Date: | Thu, 29 Oct 2020 18:54:18 +0000 |
| Subject: | Bug #80297 [Com]: password_verify won't work with double quotes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-230015@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80297&edit=1
ID: 80297
Comment by: rtrtrtrtrt at dfdfdfdf dot dfd
Reported by: brennen at swedecreek dot com
Summary: password_verify won't work with double quotes
Status: Open
Type: Bug
Package: *Encryption and hash functions
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
because you lack basics and proper error-reporting
in double quotes you need to secape $ as \$
----------------
Interactive shell
php > if(password_verify("helloworld",
"$2y$10$nqqnTXGG/W4kNWDQ6Zlx8uNbduUfYmn/iS7eKOj9fbG6iVa.3dOAi")) {echo
"Success";} else {echo "Fail";}
Notice: Undefined variable: nqqnTXGG in php shell code on line 1
Fail
Previous Comments:
------------------------------------------------------------------------
[2020-10-29 18:50:49] brennen at swedecreek dot com
Description:
------------
When using double quotes around $hash in password_verify, it always returns false. You have to use
double quotes.
Test script:
---------------
if(password_verify("helloworld",
"$2y$10$nqqnTXGG/W4kNWDQ6Zlx8uNbduUfYmn/iS7eKOj9fbG6iVa.3dOAi")) {
echo "Success";
}
else {
echo "Fail";
}
Expected result:
----------------
Success
Actual result:
--------------
Fail
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80297&edit=1