繁体   English   中英

使用Crypto ++ / AES CFB的加密无法正常工作

[英]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应该是充满了密文,但它只是仍然充满px880x44

我受此官方教程的指导: https : //www.cryptopp.com/wiki/Advanced_Encryption_Standard

ProcessDataoutstring ,然后是instring然后是length。 您已经切换了输入和输出参数dataresult (大多数API会将输出参数放在其方法声明的最后,因此可以解释该错误)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM