我用這個語句哈希與爾康密碼:
$ hashedPassword = $這個 - >安全 - >哈希($密碼)爾康PHP哈希相同的密碼生成多個結果
但這語句返回不同結果使用相同的密碼。
實施例:
設置$密碼= 我得到$ hashedPassword具有以下值:
$ 2A $ 08 $ T2Rf9IcQHTj7TpY.gsfGiexZ35/KK9kS3fLElxaw8LGXhjnE01f5K 和 $ 2A $ 08 $ E2mjApECMbRKQFZodgLkEOpDLSV/tEjTe1HV3q2LLG9UINj9M9GBm 和 $ 2A $ 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);
}
}
SOLUTION:我有我的變量 「用戶」 一個錯字,而不是 「用戶」。
我已經發布了我的代碼。我使用安全 - > checkPassword()。請讓我知道我錯過了什麼。謝謝。 –