/** * Test that values encrypted with open ssl can be decrypted with mcrypt and the reverse. * * @return void */ public function testEngineEquivalence() { $this->skipIf(!defined('MCRYPT_RIJNDAEL_128'), 'This needs mcrypt extension to be loaded.'); $restore = Security::engine(); $txt = "Obi-wan you're our only hope"; $key = 'This is my secret key phrase it is quite long.'; $salt = 'A tasty salt that is delicious'; Security::engine(new Mcrypt()); $cipher = Security::encrypt($txt, $key, $salt); $this->assertEquals($txt, Security::decrypt($cipher, $key, $salt)); Security::engine(new OpenSsl()); $this->assertEquals($txt, Security::decrypt($cipher, $key, $salt)); Security::engine(new OpenSsl()); $cipher = Security::encrypt($txt, $key, $salt); $this->assertEquals($txt, Security::decrypt($cipher, $key, $salt)); Security::engine(new Mcrypt()); $this->assertEquals($txt, Security::decrypt($cipher, $key, $salt)); }
/** * Test that values encrypted with open ssl can be decrypted with mcrypt and the reverse. * * @return void */ public function testEngineEquivalence() { $restore = Security::engine(); $txt = "Obi-wan you're our only hope"; $key = 'This is my secret key phrase it is quite long.'; $salt = 'A tasty salt that is delicious'; Security::engine(new Mcrypt()); $cipher = Security::encrypt($txt, $key, $salt); $this->assertEquals($txt, Security::decrypt($cipher, $key, $salt)); Security::engine(new OpenSsl()); $this->assertEquals($txt, Security::decrypt($cipher, $key, $salt)); Security::engine(new OpenSsl()); $cipher = Security::encrypt($txt, $key, $salt); $this->assertEquals($txt, Security::decrypt($cipher, $key, $salt)); Security::engine(new Mcrypt()); $this->assertEquals($txt, Security::decrypt($cipher, $key, $salt)); }