我正在使用Crypto ++库对文件进行哈希处理。我在行中收到错误FileStore::OpenErr at memory location 0x012FED64:

FileSource file(filename.c_str(), false, new HexEncoder(new StringSink(result)));

代码是:

#include <iostream>
#include "..\cryptopp\sha.h"
#include "..\cryptopp\hex.h"
#include "..\cryptopp\files.h"
using namespace std;

string hashFile(string filename);

int main() {
    string shahash("");
    string fileName = "D:\test.txt";
    shahash = hashFile(fileName);
    cout << shahash << endl;
    return 0;
}

string hashFile(string filename)
{
    string result;
    SHA256 hash;
    FileSource file(filename.c_str(), false, new HexEncoder(new StringSink(result)));

    file.PumpAll();
    return result;
}

并且详细错误如下:
Exception thrown at 0x764B08B2 in myproject.exe: Microsoft C++ exception: CryptoPP::FileStore::OpenErr at memory location 0x012FED64.
Unhandled exception at 0x764B08B2 in myproject.exe: Microsoft C++ exception: CryptoPP::FileStore::OpenErr at memory location 0x012FED64.

The program '[13128] myproject.exe' has exited with code 0 (0x0).

描绘该错误的屏幕截图是:

c&#43;&#43; - FileStore::OpenErr在内存位置0x012FED64-LMLPHP

这种错误的可能原因是什么?

谢谢。

最佳答案

string fileName = "D:\test.txt";

应该
string fileName = "D:\\test.txt";
\t是制表符。我敢肯定,您不想在文件名中使用该名称。

关于c++ - FileStore::OpenErr在内存位置0x012FED64,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48420744/

10-11 19:39