コード例 #1
0
ファイル: BlockCipher.php プロジェクト: axelmdev/ecommerce
 /**
  * Defined by Zend\Filter\FilterInterface
  *
  * Decrypts $value with the defined settings
  *
  * @param  string $value Content to decrypt
  * @return string The decrypted content
  */
 public function decrypt($value)
 {
     $decrypted = $this->blockCipher->decrypt($value);
     // decompress after decryption
     if (!empty($this->compression)) {
         $decompress = new Decompress($this->compression);
         $decrypted = $decompress($decrypted);
     }
     return $decrypted;
 }
コード例 #2
0
ファイル: BlockCipherTest.php プロジェクト: haoyanfei/zf2
 /**
  * Ensures that the filter allows de/encryption with compression
  *
  * @return void
  */
 public function testEncryptionWithDecryptionAndCompressionMcrypt()
 {
     if (version_compare(phpversion(), '5.4', '>=')) {
         $this->markTestIncomplete('Code to test is not compatible with PHP 5.4 ');
     }
     if (!extension_loaded('bz2')) {
         $this->markTestSkipped('This adapter needs the bz2 extension');
     }
     $filter = new BlockCipherEncryption(array('key' => 'testkey'));
     $filter->setVector('1234567890123456');
     $filter->setCompression('bz2');
     $output = $filter->encrypt('teststring');
     $this->assertNotEquals('teststring', $output);
     $input = $filter->decrypt($output);
     $this->assertEquals('teststring', trim($input));
 }
コード例 #3
0
ファイル: BlockCipherTest.php プロジェクト: pnaq57/zf2demo
 /**
  * Ensures that the filter allows de/encryption with compression
  *
  * @return void
  */
 public function testEncryptionWithDecryptionAndCompressionMcrypt()
 {
     if (!extension_loaded('bz2')) {
         $this->markTestSkipped('This adapter needs the bz2 extension');
     }
     $filter = new BlockCipherEncryption(array('key' => 'testkey'));
     $filter->setVector('1234567890123456');
     $filter->setCompression('bz2');
     $output = $filter->encrypt('teststring');
     $this->assertNotEquals('teststring', $output);
     $input = $filter->decrypt($output);
     $this->assertEquals('teststring', trim($input));
 }