我有一个简单的控制台程序,它应该使用Crypto ++库中的AES CFB算法加密文件。由于某种原因,它无法正常工作。编码部分:
byte data[16] = { 0x88, 0x44, 0x88, 0x44,
0x88, 0x44, 0x88, 0x44,
0x88, 0x44, 0x88, 0x44,
0x88, 0x44, 0x88, 0x44 };
byte result[16] = { 0x88, 0x44, 0x88, 0x44,
0x88, 0x44, 0x88, 0x44,
0x88, 0x44, 0x88, 0x44,
0x88, 0x44, 0x88, 0x44 };
//Sample key
byte key[16] = { 0x88, 0x44, 0x88, 0x44,
0x88, 0x44, 0x88, 0x44,
0x88, 0x44, 0x88, 0x44,
0x88, 0x44, 0x88, 0x44 };
//Generate random Initialization Vector
byte iv[16];
CryptoPP::AutoSeededRandomPool rnd;
rnd.GenerateBlock(iv, CryptoPP::AES::BLOCKSIZE /*16*/);
//Through VisualStudio debug/watch functionality I have found out that Crypto++ randomizer works properly so at this point "iv" contains random values
CryptoPP::CFB_Mode<CryptoPP::AES>::Encryption tmp(key, 16, iv, 1);
tmp.ProcessData(data, result, 16);
问题是在这部分的最后一行代码之后(tmp.ProcessData(data,result,16);)result
中的任何内容都没有变化。
我受这个官方教程的指导:
https://www.cryptopp.com/wiki/Advanced_Encryption_Standard