I need an example of how to use Crypto++ to generate a SHA256 hash from a std::string and output a std::string. I can\'t seem to figure it out. Everything I\'ve tried gives me i
This outputs a base64 string using the CryptoPP::Base64Encoder
:
#include "sha.h"
#include "filters.h"
#include "base64.h"
std::string SHA256HashString(std::string aString){
std::string digest;
CryptoPP::SHA256 hash;
CryptoPP::StringSource foo(aString, true,
new CryptoPP::HashFilter(hash,
new CryptoPP::Base64Encoder (
new CryptoPP::StringSink(digest))));
return digest;
}