42#ifndef _DWMCREDENCEGENERICHASH_HH_
43#define _DWMCREDENCEGENERICHASH_HH_
61 template <
size_t OutLen>
71 (key.empty() ? nullptr : (
const uint8_t *)key.data());
72 crypto_generichash_init(&_h, kp, key.size(), OutLen);
78 void Update(
const std::string & chunk)
80 crypto_generichash_update(&_h, (
const uint8_t *)chunk.data(),
90 uint8_t finalbuf[OutLen] = {0};
91 crypto_generichash_final(&_h, finalbuf,
sizeof(finalbuf));
92 return std::string((
const char *)finalbuf, OutLen);
96 crypto_generichash_state _h;
Class template that wraps sodium's crypto_generichash_* functions.
Definition DwmCredenceGenericHash.hh:63
std::string Final()
Returns the final hash.
Definition DwmCredenceGenericHash.hh:88
void Update(const std::string &chunk)
Updates the hash.
Definition DwmCredenceGenericHash.hh:78
GenericHash(const std::string &key="")
Initializes the hash.
Definition DwmCredenceGenericHash.hh:68