【问题标题】:cakephp beforsave - cipher returns random valuecakephp beforsave - 密码返回随机值
【发布时间】:2012-05-11 17:12:38
【问题描述】:

我有使用beforeSave(..) 加密一个字段的模型。 它在我的带有 WAMP 服务器的 PC 上运行良好,但是当我将它上传到服务器时,Security::cipher(..) 方法似乎返回随机值。

public function beforeSave() 
{
        if(isset($this->data[$this->alias]['somefield']))
            {
                $key = Configure::read('Security.salt');
                $cipher = Security::cipher($this->data[$this->alias]['somefield'],$key);    
                echo $cipher.'</br>'.$this->data[$this->alias]['somefield'];
                die;            
                $this->data[$this->alias]['somefield'] = $cipher;
            }
            return true;
        }

此代码在我的 PC 上返回相同的密码和值对,但在服务器上该值相同,但从该值生成的密码是随机的。我发现这篇文章CakePHP Security::cipher() is not working specifically on server - 我不知道这是否是一个问题,但它说 cipher() 使用了可能被禁用的 srand - 我如何解决这个问题 - 我无法在 php 配置中更改任何内容,我只有 ftp访问服务器。

PC 上的 PHP:5.3.9 服务器上的 PHP:5.2.17

【问题讨论】:

    标签: cakephp cakephp-2.0 encryption


    【解决方案1】:

    我发现了这个:http://groups.google.com/group/cake-php/browse_thread/thread/7e6cda2e03a7c54?pli=1 似乎是它的真正错误,我刚刚使用了这个人发布的这个功能,它工作正常。

    【讨论】:

      猜你喜欢
      • 2022-09-23
      • 2020-05-11
      • 1970-01-01
      • 2019-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-29
      相关资源
      最近更新 更多