Features: - PKCS #7 padding of messages - random IV selection - checksum validation with HMAC - tested to be compatible with many ciphers, modes and hashing algorithms. - highly customizable, but default options are most secure
Author: Michael Meyer (mmeyer2k) (m.meyer2k@gmail.com)
Inheritance: extends Cryptobase
コード例 #1
0
ファイル: AesTest.php プロジェクト: dopecode/dcrypt
 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));
 }
コード例 #2
0
ファイル: McryptTest.php プロジェクト: dopecode/dcrypt
 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));
             }
         }
     }
 }
コード例 #3
0
 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);
     }
 }