예제 #1
0
 /**
  * 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
 /**
  * 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
 /**
  * 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));
 }