我正在使用 Crypto++ 库对文件进行哈希处理。我在内存位置 0x012FED64 处收到错误 FileStore::OpenErr:
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).
描述错误的屏幕截图是:
这种错误的可能原因是什么?
谢谢。
最佳答案
string fileName = "D:\test.txt";
应该是
string fileName = "D:\\test.txt";
\t
是制表符。我很确定您不希望在您的文件名中使用它。
关于c++ - FileStore::OpenErr 在内存位置 0x012FED64,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48420744/