Esempio n. 1
0
 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);
         }
     }
 }