/** * @expectedException InvalidArgumentException */ public function testCorrupt() { $encrypted = AesCtr::encrypt($this->input, $this->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); AesCtr::decrypt($corrupt, $this->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); } }