Using Crypto++ to generate random hashes with SHA1

后端 未结 1 1644
温柔的废话
温柔的废话 2020-12-17 05:23

I need to generate a random hash using Crypto++, using SHA1. At the moment I have:

#include 
#include 
#incl         


        
1条回答
  •  渐次进展
    2020-12-17 05:57

    Just specify your namespaces correctly and carefully:

    #include 
    #include 
    #include 
    
    #include 
    
    int main()
    {
      CryptoPP::SHA1 sha1;
      std::string source = "Hello";  //This will be randomly generated somehow
      std::string hash = "";
      CryptoPP::StringSource(source, true, new CryptoPP::HashFilter(sha1, new CryptoPP::HexEncoder(new CryptoPP::StringSink(hash))));
    }
    

    0 讨论(0)
提交回复
热议问题