关于phpass的使用?
天蓬老师
天蓬老师 2017-05-16 13:00:42
0
1
823

这是它的官方文档:https://github.com/rchouinard...
官网上的说明:
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...
}

我按照官方文档改了composer.json的配置、将Phpass文件目录复制到我的项目目录下了,但是运行的时候报错了:Parse error: syntax error, unexpected 'Phpass\Hash' (T_CONSTANT_ENCAPSED_STRING) in E:\wenjian\register.php on line 2
以下是我的register.php文件代码:

<?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";
}
?>

本人PHP小白orz。。不懂为什么会报错额不是路径都对了吗= =,有用过phpass的前辈指点一下吗?谢谢

天蓬老师
天蓬老师

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

Antworte allen(1)
为情所困

你的PHP版本是多少?

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage