CakePHP Security :: cipher解密不工作 [英] CakePHP Security::cipher decrypt not working

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

问题描述

我试图使用

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.

推荐答案

请注意,您无法解密 hashed 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.

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

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 :: cipher解密不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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