![](/img/trans.png)
[英]Using std::string for key with AES encryption in Crypto++
[英]Encryption with Crypto++/AES CFB not working
我有一个简单的控制台程序,该程序应使用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);
问题是,当这个代码完成result
应该是充满了密文,但它只是仍然充满px88
和0x44
。
我受此官方教程的指导: https : //www.cryptopp.com/wiki/Advanced_Encryption_Standard
ProcessData
是outstring
,然后是instring
然后是length。 您已经切换了输入和输出参数data
及result
(大多数API会将输出参数放在其方法声明的最后,因此可以解释该错误)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.