Пример #1
0
 public function testDecrypt()
 {
     $factory = new \CryptLib\Cipher\Factory();
     $aes = $factory->getBlockCipher('aes-128');
     $aes->setKey('foobarbafoobarba');
     $mode = new \CryptLib\Cipher\Block\Mode\CFB($aes, 'bazbsomemoreizbu');
     $expect = $mode->decrypt(pack('H*', '780be9c7da419db4b2c722f3e37d90b6'));
     $expect .= $mode->decrypt(pack('H*', '59ef86341afa301f0ff758352cb596fe'));
     $expect .= $mode->finish();
     $this->assertEquals('bazbizbusomemoresomemorebazbizbu', $expect);
 }
Пример #2
0
 /**
  * @dataProvider provideTestEncryptVectors
  * @group Vectors
  */
 public function testDecrypt($cipher, $key, $iv, $expected, $data)
 {
     $cipher = new \CryptLib\Cipher\Block\Cipher\AES($cipher);
     $cipher->setKey(pack('H*', $key));
     $mode = new \CryptLib\Cipher\Block\Mode\CFB($cipher, pack('H*', $iv));
     $dec = $mode->decrypt(pack('H*', $data));
     $dec .= $mode->finish();
     $this->assertEquals($expected, strtoupper(bin2hex($dec)));
 }