加密大型文件花费太多时间
我正在尝试使用AES 128加密和解密文件。一切正常,但是要加密仅165 kb的文件需要太多时间。我检查了整个Internet,并尝试使用不同的策略,但是结果仍然需要1分钟才能加密165KB的文件。
阅读和加密方式
string keyStr = "abcdefghijklmnop";
byte key[16];
charToByte(key, keyStr.c_str());
//Key expansion
word w[4 * (Nr + 1)];
KeyExpansion(key, w);
bitset<128> data;
byte plain[16];
//Encrypt the file s.csv to s.csv.enc
ifstream in;
ofstream out;
in.open("s.csv", ios::binary);
out.open("s.csv.enc", ios::binary);
while (in.read((char*)&data, sizeof(data)))
{
divideToByte(plain, data);
encrypt(plain, w);
data = mergeByte(plain);
out.write((char*)&data, sizeof(data));
data.reset(); //Set 0
}
in.close();
out.close();
这是我从中获取代码的 : https://programmer.group/c-implementation-of-aes-加密-algorithms.html
任何帮助都将受到赞赏。
I am trying to encrypt and decrypt a file using aes 128. Everything works fine but it takes too much time to encrypt a file which is just 165 kb. I checked the whole internet and tried to use different tactics but the result is still same takes 1 minute to encrypt a 165kb file.
here is how I do the reading and encrypting
string keyStr = "abcdefghijklmnop";
byte key[16];
charToByte(key, keyStr.c_str());
//Key expansion
word w[4 * (Nr + 1)];
KeyExpansion(key, w);
bitset<128> data;
byte plain[16];
//Encrypt the file s.csv to s.csv.enc
ifstream in;
ofstream out;
in.open("s.csv", ios::binary);
out.open("s.csv.enc", ios::binary);
while (in.read((char*)&data, sizeof(data)))
{
divideToByte(plain, data);
encrypt(plain, w);
data = mergeByte(plain);
out.write((char*)&data, sizeof(data));
data.reset(); //Set 0
}
in.close();
out.close();
I took the code from:
https://programmer.group/c-implementation-of-aes-encryption-algorithms.html
any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论