我有下面的代码来加密和解密 Qt 中的 botan 文件。加密大文件时会花费大量时间,并且我想在加密/解密大文件时获取处理的字节数。是否可以?
void AES::Encrypt(SymmetricKey key, InitializationVector iv, string inFilename, string outFilename)
{
std::ifstream in(inFilename.c_str(),std::ios::binary);
std::ofstream out(outFilename.c_str(),std::ios::binary);
Pipe pipe(get_cipher("AES-256/CBC", key, iv,ENCRYPTION),new DataSink_Stream(out));
pipe.start_msg();
in >> pipe;
pipe.end_msg();
out.flush();
out.close();
in.close();
qDebug() << "Encrypted!";
}
void AES::Decrypt(SymmetricKey key, InitializationVector iv, string inFilename, string outFilename)
{
std::ifstream in(inFilename.c_str(),std::ios::binary);
std::ofstream out(outFilename.c_str(),std::ios::binary);
Pipe pipe(get_cipher("AES-256/CBC", key, iv,DECRYPTION),new DataSink_Stream(out));
pipe.start_msg();
in >> pipe;
pipe.end_msg();
out.flush();
out.close();
in.close();
qDebug() << "Decrypted!";
}