public function testCrossCompatability() { // If PHP 7.1, skip this test if (self::mcryptDeprecated()) { $this->assertTrue(true); return; } $k = 'asdf'; $p = '1234'; $c = Aes::encrypt($p, $k); $this->assertEquals($p, Mcrypt::decrypt($c, $k)); }
public function testEngine() { // If PHP 7.1, skip this test if (self::mcryptDeprecated()) { $this->assertTrue(true); return; } $modes = self::mcryptModes(); $ciphers = self::mcryptCiphers(); foreach (hash_algos() as $algo) { $input = 'AAAAAAAA'; $key = 'AAAAAAAA'; $cost = 0; foreach ($modes as $mode) { foreach ($ciphers as $cipher) { $encrypted = Mcrypt::encrypt($input, $key, $cost, $cipher, $mode, $algo); $this->assertEquals($input, Mcrypt::decrypt($encrypted, $key, $cost, $cipher, $mode, $algo)); } } } }
public function testCrossDecryptFailure() { $pw = 'password'; $encrypted = \Dcrypt\Aes::encrypt('hello world', $pw); try { \Dcrypt\AesCtr::decrypt($encrypted, $pw); $this->assertTrue(false); } catch (\Exception $ex) { $this->assertTrue(true); } try { \Dcrypt\Mcrypt::decrypt($encrypted, $pw); $this->assertTrue(false); } catch (\Exception $ex) { $this->assertTrue(true); } $encrypted = \Dcrypt\AesCtr::encrypt('hello world', $pw); try { \Dcrypt\Aes::decrypt($encrypted, $pw); $this->assertTrue(false); } catch (\Exception $ex) { $this->assertTrue(true); } }