示例#1
0
 public function testEncryptDecrypt()
 {
     $key = 'foobar';
     $data = 'very secret';
     $iv = Crypt::getiv();
     $encrypted = Crypt::encrypt($data, $key, $iv);
     $this->assertNotEquals($data, $encrypted);
     $decrypted = Crypt::decrypt($encrypted, $key, $iv);
     $this->assertEquals($data, $decrypted);
 }
示例#2
0
文件: storage.php 项目: photon/photon
 /**
  * Get a value from the storage.
  *
  * @required public function get($offset)
  */
 public function get($offset)
 {
     if (isset($this->deleted[$offset])) {
         return null;
     }
     if (isset($this->cache[$offset])) {
         return $this->cache[$offset];
     }
     if (strlen($this->iv) && isset($this->cookie['scs-' . $offset])) {
         return Crypt::decrypt($this->cookie['scs-' . $offset], Conf::f('secret_key'), $this->iv);
     }
     return null;
 }