search

Home  >  Q&A  >  body text

About the use of phpass?

This is its official document: https://github.com/rchouinard...
Instructions on the official website:
Examples

Use the default bcrypt adapter:

<?php
// Default configuration - bcrypt adapter, 2^12 (4,096) iterations
$phpassHash = new \Phpass\Hash;
Use the PBKDF2 adapter:

<?php
// Customize hash adapter - PBKDF2 adapter, 15,000 iterations
$adapter = new \Phpass\Hash\Adapter\Pbkdf2(array (
    'iterationCount' => 15000
));
$phpassHash = new \Phpass\Hash($adapter);
Create and verify a password hash:

<?php
// Create and verify a password hash from any of the above configurations
$passwordHash = $phpassHash->hashPassword($password);
if ($phpassHash->checkPassword($password, $passwordHash)) {
    // Password matches...
} else {
    // Password doesn't match...
}

I changed the configuration of composer.json according to the official documentation and copied the Phpass file directory to my project directory, but when I ran it, an error was reported: Parse error: syntax error, unexpected 'Phpass\Hash' (T_CONSTANT_ENCAPSED_STRING) in E:\wenjian\register.php on line 2;
The following is my register.php file code:

<?php
$phpassHash=new Phpass\Hash;
$adapter=new Phpass\Hash\Adapter\Pbkdf2(array(
    'iterationCount'=>15000
));
$phpassHash=new \Phpass\Hash($adapter);
$password="kkkkkkkk";
$passwordHash=$phpassHash->hashPassword($password);
if($phpassHash->checkPassword($password,$passwordHash)){
    echo "ok";
}else{
    echo "error";
}
?>

I am a PHP novice orz. . I don’t understand why the error is reported. Isn’t the path correct? = = Can anyone with experience with phpass give me some advice? Thank you

天蓬老师天蓬老师2749 days ago816

reply all(1)I'll reply

  • 为情所困

    为情所困2017-05-16 13:02:42

    What is your PHP version?

    reply
    0
  • Cancelreply