On Thu, Jun 15, 2023 at 12:16 AM fa <fery....@gmail.com> wrote:
>
> I tried two methods:
>
>
> 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.

std::ifstream does not have a ctor that takes a std::filesystem::path.
See https://cplusplus.com/reference/fstream/ifstream/ifstream/ . It
looks like you need to do something like
https://stackoverflow.com/a/45401869 .

Jeff

-- 
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-users+unsubscr...@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.

Reply via email to