beforeSave(..)
1 つのフィールドを暗号化するために使用するモデルがあります。私のPCではWAMPサーバーで問題なく動作しますが、サーバーにアップロードすると、 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 specificly on server - I don't know if this is a problem but it does that cipher() uses srand that may be disabled - how I can't fix this - I cant PHPの設定を変更してください。サーバーへのftpアクセスしかありません。
PC 上の PHP: 5.3.9 サーバー上の PHP: 5.2.17