FileStore::OpenErr 在内存位置 0x012FED64
FileStore::OpenErr at memory location 0x012FED64
我正在使用 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).
描述错误的屏幕截图是:
出现这种错误的可能原因是什么?
谢谢。
可以使用 errno 以编程方式检查它吗?添加到文件开头:
#include <cerrno> // for errno
#include <cstring> // for strerror
然后将你的抛出哈希文件调用包装到 try 中:
try
{
shahash = hashFile(fileName);
}
catch(CryptoPP::FileStore::OpenErr const&)
{
cout << "Error: " << strerror(errno) << '\n';
return 42;
}
如果在堆栈展开期间没有在析构函数中进一步失败调用,则 errno 告诉 cout 该文件有什么问题。您还可以摆脱未处理的异常崩溃。
我的猜测是 "D:\test.txt"
是错误的文件名,您需要 "D:\test.txt"
string fileName = "D:\test.txt";
应该是
string fileName = "D:\test.txt";
\t
是制表符。我很确定您不希望在您的文件名中使用它。
我正在使用 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).
描述错误的屏幕截图是:
出现这种错误的可能原因是什么?
谢谢。
可以使用 errno 以编程方式检查它吗?添加到文件开头:
#include <cerrno> // for errno
#include <cstring> // for strerror
然后将你的抛出哈希文件调用包装到 try 中:
try
{
shahash = hashFile(fileName);
}
catch(CryptoPP::FileStore::OpenErr const&)
{
cout << "Error: " << strerror(errno) << '\n';
return 42;
}
如果在堆栈展开期间没有在析构函数中进一步失败调用,则 errno 告诉 cout 该文件有什么问题。您还可以摆脱未处理的异常崩溃。
我的猜测是 "D:\test.txt"
是错误的文件名,您需要 "D:\test.txt"
string fileName = "D:\test.txt";
应该是
string fileName = "D:\test.txt";
\t
是制表符。我很确定您不希望在您的文件名中使用它。