2#include <openssl/sha.h>
11 SHA256_Init(&context);
12 SHA256_Update(&context, data, length);
13 std::vector<unsigned char> buffer(SHA256_DIGEST_LENGTH);
14 SHA256_Final(buffer.data(), &context);
30 return sha256(data.data(), data.size());
40 return SHA256_DIGEST_LENGTH; ;
45 std::ostringstream result;
47 for (std::string::size_type i = 0; i < bytes.size();i++)
49 result << std::hex << std::setfill(
'0') << std::setw(2) << (uppercase ? std::uppercase : std::nouppercase) << (
int)bytes[i];
50 if (i != bytes.size() - 1)
52 result << std::setw(1) <<
" ";
std::vector< unsigned char > hash()
Hash the data buffer.
static std::vector< unsigned char > sha256(const unsigned char *data, size_t length)
SHA256 hash.
size_t size(void)
Digest size.
static std::string print(std::vector< unsigned char > bytes, bool uppercase=true)
Print Bytestring.
void reset()
Reset data buffer.