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

Phalcon php哈希相同的密码会产生多个结果,php,hash,phalcon,Php,Hash,Phalcon,我使用此语句将密码与Phalcon: $hashedPassword=$this->security->hash($password) 但此语句使用相同的密码返回不同的结果 示例: 设置$password=123 我获得具有以下值的$hashedPassword: $2a$08$T2Rf9IcQHTj7TpY.gsfGiexZ35/KK9kS3fLElxaw8LGXhjnE01f5K 和 $2a$08$E2mjApECMbRKQFZodgLkEOpDLSV/tEjTe1HV3q2LLG9UINj

我使用此语句将密码与Phalcon:
$hashedPassword=$this->security->hash($password)

但此语句使用相同的密码返回不同的结果

示例:
设置$password=123 我获得具有以下值的$hashedPassword:

$2a$08$T2Rf9IcQHTj7TpY.gsfGiexZ35/KK9kS3fLElxaw8LGXhjnE01f5K$2a$08$E2mjApECMbRKQFZodgLkEOpDLSV/tEjTe1HV3q2LLG9UINj9M9GBm$2a$08$azmgsmmg2xruevzp6tx2ucwgpzmzuwiccxbljnqorwdsssnt4zc.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);
    }
}
if($this->request->isPost()==true)
{
$email=$this->request->getPost(“电子邮件”);
$password=$this->request->getPost(“密码”);
$conditions=“电子邮件=?1和管理员=?2”;
$parameters=array(1=>$email,2=>1);
$users=users::findFirst(数组(
美元条件,
“绑定”=>$parameters
));
如果($用户)
{
$security=new-Phalcon\security();
$checkHashValue=$security->checkHash($password,$user->password);
if($checkHashValue)
{
$this->flash->success($users->fullname);
}
其他的
{
//打印调试信息
$hash=$security->hash($password);
$checkHash=$security->checkHash($password,$hash);
$this->flash->错误(“密码:”。$Password。
“
哈希:.$Hash。”
检查哈希:.$checkHash。 “
检查HashValue:”.$checkHashValue); } } 其他的 { $this->flash->error($password); } }


解决方案:我的变量“user”而不是“users”中有一个输入错误。

这就是它的工作原理。它每次都创建一个随机散列。要检查密码,请使用
security->checkPassword()
解决方案:我的变量“user”而不是“users”中有一个输入错误。

我已经发布了我的代码。我已经使用了security->checkPassword()。请让我知道我错过了什么。非常感谢。