php password_verify函数没有匹配

时间:2017-04-04 02:52:01

标签: php hash passwords verify

我想使用password_verify登录,这是我的代码

$DB1->select('Idx,Email,Password');
$DB1->from('User');
$DB1->where('Email',$Email);
$result = $DB1->get()->result();
// get_where('4SUser',array('Email' => $Email))->result();

if(password_verify($this->input->post('Password'), $result[0]->Password)) {
    $this->response("Login Success");
} else {
    $this->response("Login Failed");
}

然后,这是我加入会员时使用password_hash

---更新更新     $ hash = password_hash($ this-> input-> post(' Password'),PASSWORD_DEFAULT);

我不知道它为什么会返回错误;

使用密码tester1234和DB,$ 2y $ 10 $ FZ7WV5cn5OL58t5hgM3cBeb2NRfXk7IrxNzyBiBMYZA.HYtXSSDjS

这是DB值。

但是当我输入密码时测试hash_password时,

"$2y$10$KP1MG1abyMBD/gR82WmKoONvW/VvblYix13We6MNeRKdbDg0ufRQC"
"$2y$10$2H7Lx340yXWBFXFgv2LUJuN.luODBmJtNwfrCVQh2A37O0Es9Ud/K"
"$2y$10$.xUl/0zKnt.m26MSVwUBDOFVx29Bd8XxNyI.t7RqonfP8pmwIIVRC"

每次更改

是否导致错误与密码不匹配?

请帮帮我

---更新问题

$HashInputPassword = password_hash($this->input->post('Password'), PASSWORD_DEFAULT);
$UserPassword = $result[0]->Password;

if($HashInputPassword === $UserPassword) {
    $this->response("Login Success");
} else {
    $this->response("Login Failed");
}  

0 个答案:

没有答案