cakephp对密码的哈希处理不一样


cakephp not hashing passwords the same

我正在尝试用CakePHP为我的网站编写一个密码重置函数。我已经尝试过使用$auth->hashPasswords$auth->password,甚至Security::hash,但没有什么能正确地对其进行哈希处理。我尝试使用foobar登录,注意到用于尝试登录的哈希:cfb9fabf02497f9090cbba6b03da4764212cea407

但是重置使得foobar散列为CCD_ 5。

我做错了什么?

我的代码:

$this->data['Player']['password'] = $this->Auth->password($this->data['Player']['password']);
$this->Player->save($this->data);

问题是,如果您有一个"username"answers"password"字段(在CakePHP 1.3或更早版本中),那么名为"password"的字段会自动散列。因此,当你手动操作时,实际上你要对它进行两次哈希。

您可以将其重命名为其他名称,如"password1"、"mypass"、"toiletpaper"。。。等等,这样可以防止它被自动散列,或者你可以删除你的额外散列。