1.
void CryptoHashes::makeFileHash(const QString &filePath)
{
FileSource f(filePath.toStdString().c_str(), true, new HashFilter(hash, new HexEncoder(new StringSink(digest))));
}
2.
void CryptoHashes::makeFileHash(const QString &filePath)
{
std::filesystem::path _path { std::filesystem::u8path(filePath.toStdString()) };
std::ifstream m_file(_path, std::ios::in);
FileSource f(m_file, true, new HashFilter(hash, new HexEncoder(new StringSink(digest))));
}
the only exception is that when I tried method 2, it always calculated hash of NULL, no matter which file I selected.
--
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/CAH8yC8m09ompC0z8KH%3D7XFQs6nP%3D2vD8hbZpq5ZwF4Da%2BzJVCw%40mail.gmail.com.
Hi Jeffrey Walton
Sorry I answered late.
std::filesystem::path _path { std::filesystem::u8path(filePath.toStdString()) };
std::string _path_string { _path.u8string() };
std::ifstream m_file(_path_string, std::ios::in);
FileSource f(m_file, true, new HashFilter(hash, new HexEncoder(new StringSink(digest))));
ERROR:
The error message you're encountering suggests that there's an issue with reading the file specified by
_path_string
in your code. The error is thrown byCryptoPP::FileStore
, indicating a problem while trying to read the file.Here are a few possible reasons for this error:
Incorrect file path: Double-check that
filePath.toStdString()
returns the correct file path. Ensure that the file exists at that location and that you have read permissions.File permission issues: Make sure that the file you're trying to read has proper read permissions set. Check the file's permissions and adjust them if necessary.
File not found: If the file specified by
_path_string
doesn't exist, you'll encounter this error. Verify that the file exists at the given path and that there are no typos in the file name or path.Insufficient privileges: If your program doesn't have sufficient privileges to access the file, you may encounter this error. Ensure that your program has the necessary permissions to read files from the specified location.
Encoding issues: It's possible that the file you're trying to read contains data encoded in an incompatible format. Ensure that the file is in a readable format and that it's not corrupted or encoded in a way that the
std::ifstream
cannot handle.To pinpoint the exact cause of the error, you can try adding some error handling and debugging statements to your code. For example, you can check if the file exists before attempting to read it using
std::filesystem::exists(_path)
.Here's an updated version of your code that includes some error handling:
cpp
By using this updated code, you should be able to identify the specific issue causing the
CryptoPP::FileStore::ReadErr
error and handle it appropriately.
--
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/cb4562d6-7ea9-4b7c-9a6f-c280421fffc1n%40googlegroups.com.
Hi One Sini
Thanks for your reply, but my problem is not related to file permission or insufficient privileges. No errors occurred when I do this operation with English characters, but errors occur when I use UTF-8 characters. I think the Cryptopp library has a problem with UTF-8 characters.