C++ 在Qt中使用botan加密大文件时如何获得加密/解密进度

C++ 在Qt中使用botan加密大文件时如何获得加密/解密进度,c++,qt,botan,C++,Qt,Botan,我有下面的代码来加密和解密Qt中的botan文件。 当加密大文件时,它会花费很多时间,我想得到加密/解密大文件时处理的字节数。可能吗 void AES::Encrypt(SymmetricKey key, InitializationVector iv, string inFilename, string outFilename) { std::ifstream in(inFilename.c_str(),std::ios::binary); std::ofstream

我有下面的代码来加密和解密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!";
}
void AES::Encrypt(SymmetricKey、InitializationVector iv、字符串填充名、字符串输出文件名)
{
std::ifstream-in(inFilename.c_str(),std::ios::binary);
std::ofstreamout(outFilename.c_str(),std::ios::binary);
管道(获取密码(“AES-256/CBC”,密钥,iv,加密),新的数据链(out);
pipe.start_msg();
在>>管道中;
pipe.end_msg();
out.flush();
out.close();
in.close();
qDebug()>管道;
pipe.end_msg();
out.flush();
out.close();
in.close();

qDebug()如果您查看Botan文档中关于的内容,会有一个关于处理大文件和限制内存使用的讨论。在该部分的末尾,是一个代码片段,显示了如何使用限制缓冲区处理大文件。通过在其中添加一些代码,我想您将能够防止加密操作耗尽内存It’很好,可以从循环中发出Qt进度信号。

谢谢,您的回答非常有用