/** * Ensures that the filter follows expected behavior * * @return void */ public function testBasicBlockCipher() { if (!extension_loaded('mcrypt')) { $this->markTestSkipped('Mcrypt extension not installed'); } $filter = new EncryptFilter(array('adapter' => 'BlockCipher', 'key' => 'testkey')); $valuesExpected = array('STRING' => 'STRING', 'ABC1@3' => 'ABC1@3', 'A b C' => 'A B C'); $enc = $filter->getEncryption(); $filter->setVector('1234567890123456'); $this->assertEquals('testkey', $enc['key']); foreach ($valuesExpected as $input => $output) { $this->assertNotEquals($output, $filter($input)); } }
/** * Ensures that the filter allows setting options de/encryption * * @return void */ public function testGetSetEncryption() { if (!extension_loaded('mcrypt')) { $this->markTestSkipped('Mcrypt extension not installed'); } $filter = new EncryptFilter(array('adapter' => 'Mcrypt', 'key' => 'testkey')); $filter->setVector('testvect'); $filter->setEncryption(array('mode' => MCRYPT_MODE_ECB, 'algorithm' => MCRYPT_3DES)); $this->assertEquals(array('key' => 'testkey', 'algorithm' => MCRYPT_3DES, 'algorithm_directory' => '', 'mode' => MCRYPT_MODE_ECB, 'mode_directory' => '', 'vector' => 'testvect', 'salt' => false), $filter->getEncryption()); }