php哈希相同的密码产生多个结果


Phalcon php hash same password produces multiple result

我使用这个语句来散列密码:
$ hashedPassword = $ this ->安全->哈希(密码)

但是对于相同的密码,该语句返回不同的结果。

例子:
设置密码美元= 123 我得到$ hashhedpassword与以下值:

2美元08年T2Rf9IcQHTj7TpY.gsfGiexZ35美元/KK9kS3fLElxaw8LGXhjnE01f5K 2美元08年E2mjApECMbRKQFZodgLkEOpDLSV美元/tEjTe1HV3q2LLG9UINj9M9GBm 2美元08年美元aZmgsMmG2xRueVzP6tkx2ucWGPZMzUwIccXbLJnqoRwDsSnT4zc.q


这是我用来检查用户密码的代码,
请让我知道我错过了什么。

if ($this->request->isPost() == true)
{
    $email = $this->request->getPost ("email");
    $password = $this->request->getPost ("password");
    $conditions = "email = ?1 AND admin = ?2";
    $parameters = array(1 => $email, 2 => 1);
    $users = Users::findFirst(array(
        $conditions,
        "bind" => $parameters
    ));
    if($users)
    {
        $security = new Phalcon'Security();
        $checkHashValue = $security->checkHash($password, $user->password);
        if($checkHashValue)
        {
            $this->flash->success($users->fullname);
        }
        else
        {
            //Print debug information
            $hash = $security->hash($password);
            $checkHash = $security->checkHash($password, $hash);
            $this->flash->error("Password: ". $password. 
            "<br/>Hash: " . $hash . "<br/>Check Hash: " . $checkHash . 
            "<br/>Check HashValue: ". $checkHashValue);
        }
    }
    else
    {
        $this->flash->error($password);
    }
}

解决方案:我的变量"user"有一个错别字,而不是"users"

这就是它应该如何工作。它每次都会创建一个随机散列。查看密码:security->checkPassword()

解决方案:我的变量"user"有一个错别字,而不是"users"