Jump to content

password verify throwing weird error


wilsoc31

Recommended Posts

Can anyone please help me?  normally i can fix this error but for some reason it just doesnt make since in this case to me.  

 

The error im getting is:

Parse error: syntax error, unexpected ''$2y$10$fFYyZWTdAcewqFByXX5Wvu' (T_CONSTANT_ENCAPSED_STRING) in

/home/xxxx/xxxxxxxx.com/pass_test.php on line 2

 

here is the code:

<?php 
$hash = '$2y$10$fFYyZWTdAcewqFByXX5Wvu/UuAk8dwYYjOV27SN/9RPea6TeU9Q0u';

if (password_verify('rasmuslerdorf', $hash)) {
    echo 'Password is valid!';
} else {
    echo 'Invalid password.';
}

echo "<br>";
$options10 = [ 'cost' => 10,];
$hash = password_hash('test',PASSWORD_BCRYPT,$options10);
echo "10: ".$hash;
echo "<br>";
?>
Link to comment
Share on other sites

Actually, in line 2 you are showing

$hash = '$2y$10$fFYyZWTdAcewqFByXX5Wvu/UuAk8dwYYjOV27SN/9RPea6TeU9Q0u';

I have highlighted in red to what is exactly causing the error "/". I came across this a while back with my tests but just ended moving to PASSWORD_DEFAULT and prepared it for it's changes in the future.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.