About the use of phpass?
天蓬老师
天蓬老师 2017-05-16 13:00:42
0
1
814

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

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(1)
为情所困

What is your PHP version?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template