我有一个模型,它使用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 -我不知道这是不是一个问题,但它说密码()使用srand,这可能是被禁用的-我如何解决这个问题-我不能改变php配置中的任何东西,我只能通过ftp访问服务器。
PC上的PHP : 5.3.9服务器上的PHP : 5.2.17
发布于 2012-05-12 02:09:01
我发现了这个:http://groups.google.com/group/cake-php/browse_thread/thread/7e6cda2e03a7c54?pli=1它似乎是真正的bug,我只是使用了这个人发布的函数,它工作得很好。
https://stackoverflow.com/questions/10555784
复制相似问题