cakephp sha1密码保存在mysql中
我忘记了 cakephp 应用程序中的密码功能。该函数将请求电子邮件地址,找到该用户,生成新密码,将其转换为 sha1 并将其保存到数据库,通过电子邮件将内容发送给用户。
无论如何,我遇到了问题,生成的 sha1 密码与保存的密码不同。
我已将信息调用到屏幕上以显示正在发生的情况:
临时密码- lHQcVp4(来自函数) 块引用
SHA1 密码- 0ee4ae757733f458b9e395a8457c2ef307af99f0(来自 sha1($user['User']['tmp_password']);
身份验证密码密码- 93df9bd251620d0634235c22f4ab6fe9ad5421f4(来自:$this->Auth->password($user['User']['tmp_password']);)
保存密码后的数据库记录- 13ef648db45cc62b593c3943646806af06846016 (FROM $this->User->field('password');)
我按如下方式保存数据: $this->User->save($user, false)
为什么会有所不同全部 3 次我都无法解决,
谢谢。
I have forgot password feature in my cakephp application. The function for this will request the email address, find this user, generate a new password, convert it to sha1 and save it to the database, emailing the contents to the user.
Anyway I am having issues, the generated sha1 password is different to the one being saved.
I have called the info to the screen to show what is happening:
TEMP PASSWORD- lHQcVp4 (FROM THE FUNCTION)
BlockquoteSHA1 PASSWORD- 0ee4ae757733f458b9e395a8457c2ef307af99f0 (FROM sha1($user['User']['tmp_password']);
Auth Password PASSWORD- 93df9bd251620d0634235c22f4ab6fe9ad5421f4 (FROM: $this->Auth->password($user['User']['tmp_password']);)
DB Record After Save PASSWORD- 13ef648db45cc62b593c3943646806af06846016 (FROM $this->User->field('password');)
I am saving the data as follows: $this->User->save($user, false)
Why would it come though differently all 3 times? I cannot work it out. Very strange.
Thankyou
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这将简单地散列密码并输出文本。
这将使用 core.php 中定义的 cakephp salt 来散列密码。这就是为什么你会看到差异
如果你只是将密码值设置为 $user['User']['password'] 并调用 save() ,Auth 可能会再次对密码进行哈希处理,因为它不认识你'我们已经对其进行了哈希处理。您是否尝试过将密码设置为 $user['User']['password'] 并调用 save() ?让 Auth 为您处理哈希。
This will simply hash the password and output the text
This hashes the password with the cakephp salt defined in core.php. This is why you see a difference
If you simply set the password value to $user['User']['password'] and call save() on it, Auth might be hashing the password again since it doesn't know you've already hashed it. Have you tried just setting the password to $user['User']['password'] and calling save() on it? Let Auth handle the hashing for you.