note 115120 added to function.password-verify
| From: | Anonymous | Date: | Thu, 29 May 2014 01:40:36 +0000 |
| Subject: | note 115120 added to function.password-verify | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199643@lists.php.net to get a copy of this message | ||
If you get incorrect false responses from password_verify when manually including the hash variable
(eg. for testing) and you know it should be correct, make sure you are enclosing the hash variable
in single quotes (') and not double quotes (").
PHP parses anything that starts with a $ inside double quotes as a variable:
<?php
// this will result in 'Invalid Password' as the hash is parsed into 3 variables of
// $2y, $07 and $BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq
// due to it being enclosed inside double quotes
$hash = "$2y$07$BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq";
// this will result in 'Password is valid' as variables are not parsed inside single
quotes
$hash = '$2y$07$BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq';
if (password_verify('rasmuslerdorf', $hash)) {
    echo 'Password is valid!';
} else {
    echo 'Invalid password.';
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 58.106.44.20
----
Manual Page -- http://php.net/manual/en/function.password-verify.php
Edit -- https://master.php.net/note/edit/115120
Del: integrated -- https://master.php.net/note/delete/115120/integrated
Del: useless -- https://master.php.net/note/delete/115120/useless
Del: bad code -- https://master.php.net/note/delete/115120/bad+code
Del: spam -- https://master.php.net/note/delete/115120/spam
Del: non-english -- https://master.php.net/note/delete/115120/non-english
Del: in docs -- https://master.php.net/note/delete/115120/in+docs
Del: other reasons-- https://master.php.net/note/delete/115120
Reject -- https://master.php.net/note/reject/115120
Search -- https://master.php.net/manage/user-notes.php