好吧,我从这里下载了Rijndael的资源:http://www.codeproject.com/Articles/1380/A-C-Implementation-of-the-Rijndael-Encryption-Decr
我有以下代码:
int AutoUpdater::GetVersion()
{
std::ifstream file("ver.dat", std::ios::out );
if(file.fail())
return 0;
file.seekg(0,std::ios::end);
int len = (int)file.tellg();
file.seekg(0,std::ios::beg);
char* line = new char[len];
file.read(line,len);
file.close();
CRijndael crypt;
crypt.MakeKey("MIUJkHyHnjHyGtqO", "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16, 16);
char * decrypted = new char[len];
crypt.Decrypt(line,decrypted,len);
delete[] line;
delete [] decrypted;
return atoi(line);
}
但是它给出了此错误:“数据不是块大小的倍数”
我要加密的文件必须具有固定长度?
最佳答案
用尾随零填充以填充块大小。您也可以考虑给字节长度加上前缀,以恢复原始的精确长度。
关于c++ - 块长度-Rijndael算法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11698363/