public function testEncryptWithoutPadding() { $this->mcrypt->setKey($this->key); $this->mcrypt->setSalt($this->salt); $this->setExpectedException('Zend\\Crypt\\Symmetric\\Exception\\InvalidArgumentException', 'You have to specify a padding method'); $ciphertext = $this->mcrypt->encrypt($this->plaintext); }
public function testEncryptDecrypt() { $this->mcrypt->setKey($this->key); $this->mcrypt->setPadding(new PKCS7()); $this->mcrypt->setSalt($this->salt); foreach ($this->mcrypt->getSupportedAlgorithms() as $algo) { foreach ($this->mcrypt->getSupportedModes() as $mode) { $this->mcrypt->setAlgorithm($algo); $this->mcrypt->setMode($mode); $encrypted = $this->mcrypt->encrypt($this->plaintext); $this->assertTrue(!empty($encrypted)); $decrypted = $this->mcrypt->decrypt($encrypted); $this->assertTrue($decrypted !== false); $this->assertEquals($decrypted, $this->plaintext); } } }