這是它的官方文件: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 'PhpassHash' (T_CONSTANT_ENCAPSED_STRING) in E: wenjianregister.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的前輩指點一下嗎?謝謝
你的PHP版本是多少?