0

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

4

1 に答える 1

0

私はこれを見つけました: http://groups.google.com/group/cake-php/browse_thread/thread/7e6cda2e03a7c54?pli=1本当のバグのようです。この男が投稿したこの関数を使用したところ、問題なく動作しました。

于 2012-05-11T18:09:00.597 に答える