public function testEncrypt() { $factory = new \CryptLib\Cipher\Factory(); $aes = $factory->getBlockCipher('aes-128'); $aes->setKey('foobarbafoobarba'); $mode = new \CryptLib\Cipher\Block\Mode\CFB($aes, 'bazbsomemoreizbu'); $expect = $mode->encrypt('bazbizbusomemore'); $expect .= $mode->encrypt('somemorebazbizbu'); $expect .= $mode->finish(); $this->assertEquals('780be9c7da419db4b2c722f3e37d90b659ef86341afa301f0ff758352cb596fe', bin2hex($expect)); }
/** * @dataProvider provideTestEncryptVectors * @group Vectors */ public function testEncrypt($cipher, $key, $iv, $data, $expected) { $cipher = new \CryptLib\Cipher\Block\Cipher\AES($cipher); $cipher->setKey(pack('H*', $key)); $mode = new \CryptLib\Cipher\Block\Mode\CFB($cipher, pack('H*', $iv)); $enc = $mode->encrypt(pack('H*', $data)); $enc .= $mode->finish(); $this->assertEquals($expected, strtoupper(bin2hex($enc))); }