Caleb Cushing ( xenoterracide ) wrote:
> can anyone give me an example of how to create a sha1sum given the
> path? (fyi I'm using boost::filesystem for path's)
> 
Something like this should work:

#include <crypto++/sha.h>
#include <crypto++/hex.h>
#include <crypto++/files.h>

std::string getSHA1Hash(const boost::filesystem::path& p_file, bool 
p_upperCase)
{
     std::string result;
     try
     {
         CryptoPP::SHA1 hash;
         CryptoPP::FileSource(p_file.file_string().c_str(),true,new 
CryptoPP::HashFilter(hash,new CryptoPP::HexEncoder(new 
CryptoPP::StringSink(result),p_upperCase)));
     }
     catch (const std::exception& e) {
         throw ... // some exception
     }
     return result;
}


Regards, Peter.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

Reply via email to