【问题标题】:CakePHP Security::cipher decrypt not workingCakePHP Security::cipher 解密不起作用
【发布时间】:2010-11-01 16:39:16
【问题描述】:

我正在尝试使用

解密散列字符串
Security::cipher($strHashedPassword, Configure::read('Security.salt'));

似乎没有给出预期的结果。有人对这个有经验么?从文档看来,这应该可以工作。

【问题讨论】:

    标签: security cakephp encryption


    【解决方案1】:

    请注意,您无法解密散列字符串Hashes 根据定义是不可逆的。它们不能被解密,因为它们一开始没有加密,它们被散列。如果您真的想解密密码哈希(由 AuthComponent 生成?),那么您就不走运了。

    Security::cipher 只能解密它也加密的字符串,在这种情况下,您将谈论的是密文,而不是散列。

    如果你能证明这不会打印“test”:

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

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

    【讨论】:

    • 但对我来说,下面的代码正在工作... , $c = Security::cipher('testing hash', Configure::read('Security.salt')); $cc = Security::cipher($c, Configure::read('Security.salt'));回声 $cc;
    • @Vivek 完全符合预期。也许你误解了我写的内容。
    • @-deceze 。真的很困惑。
    • @Vivek 问题是关于使用Security::cipher 解密哈希。答案是这是不可能的,Security::cipher 只能按照你和我展示的方式工作。
    【解决方案2】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-30
    • 1970-01-01
    • 2018-03-18
    • 1970-01-01
    • 1970-01-01
    • 2014-02-24
    相关资源
    最近更新 更多