/** * @expectedException InvalidArgumentException */ public function testEngine() { $input = 'AAAAAAAA'; $key = 'AAAAAAAA'; $encrypted = Aes::encrypt($input, $key); $this->assertEquals($input, Aes::decrypt($encrypted, $key)); // Perform a validation by replacing a random byte to make sure // the decryption fails. After enough successful runs, // all areas of the cypher text will have been tested // for integrity $corrupt = self::swaprandbyte($encrypted); Aes::decrypt($corrupt, $key); }
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); } }
public static function repoEncodeWeb($repo) { return base32_encode(\Dcrypt\Aes::encrypt($repo, self::key . \Session::getId() . self::githubId())); }