CakePHP Security ::密码解密不起作用 [英] CakePHP Security::cipher decrypt not working

查看:199
本文介绍了CakePHP Security ::密码解密不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

Security::cipher($strHashedPassword, Configure::read('Security.salt'));

似乎没有给出所需的结果。有谁有任何经验吗?

doesn't seem to be giving the desired result. Does anyone have any experience with this? From the docs it looks like this should work.

推荐答案

请注意,您无法解密散列 string 哈希根据定义是不可逆转的。他们不能被解密,因为他们不是加密开始,他们是散列。如果你真的想解密一个密码哈希(由AuthComponent产生的),你就不幸了。

Please note that you cannot decrypt a hashed string. Hashes are irreversible by definition. They can't be decrypted because they're not encrypted to begin with, they're hashed. If you're really trying to decrypt a password hash (as produced by the AuthComponent?) you're out of luck.

安全性::密码只能解密它加密的字符串,在这种情况下,您将会谈论密文,而不是散列。

Security::cipher can only decrypt strings that it encrypted as well, in which case you'd be talking about a cipher text, not a hash.

如果您可以证明这不打印测试:

If you can demonstrate that this doesn't print "test":

$cipherText = Security::cipher('test', Configure::read('Security.salt'));
echo Security::cipher($cipherText, Configure::read('Security.salt'));

您在Cake中发现了一个错误,很可能是由 @infinity 。否则,你正在尝试不可能的事情。

you have found a bug in Cake, most likely the one linked to by @infinity. Otherwise, you're trying something impossible.

这篇关于CakePHP Security ::密码解密不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆