#include <icy/crypto/hash.h>Incremental cryptographic hash engine wrapping OpenSSL EVP digest functions.
Construct with an algorithm name recognized by OpenSSL (e.g. "sha256", "md5"). Feed data with one or more calls to update(), then call digest() or digestStr() to finalize and retrieve the result. Call reset() to reuse the engine for a new computation without reallocating the context.
| Return | Name | Description |
|---|---|---|
Hash | Constructs a Hash engine for the given algorithm. | |
~Hash | Destroys the Hash engine and releases OpenSSL resources. | |
void | update | Feeds a single character into the digest computation. |
void | update | Feeds a string view into the digest computation. |
void | update | Feeds a raw memory buffer into the digest computation. |
const ByteVec & | digest | Finalizes the digest computation and returns the raw binary result. |
std::string | digestStr | Finalizes the digest computation and returns the result as a raw binary string (not hex-encoded). Use icy::hex::encode() on digest() if you need a printable representation. |
void | reset | Resets the digest context and clears the cached result, allowing the engine to be reused for a new computation with the same algorithm. |
const std::string & | algorithm const | Returns the algorithm name this engine was constructed with. |
Hash(const std::string & algorithm)Constructs a Hash engine for the given algorithm.
algorithm OpenSSL digest name (e.g. "sha256", "sha1", "md5").std::runtime_error if the algorithm is not recognized by OpenSSL.~Hash()Destroys the Hash engine and releases OpenSSL resources.
void update(char data)Feeds a single character into the digest computation.
data The byte to hash.void update(std::string_view data)Feeds a string view into the digest computation.
data The data to hash.void update(const void * data, size_t length)Feeds a raw memory buffer into the digest computation.
This method may be called multiple times for streaming large inputs.
data Pointer to the input buffer.
length Number of bytes to hash from data.
const ByteVec & digest()Finalizes the digest computation and returns the raw binary result.
The result is computed on the first call and cached; subsequent calls return the same value without recomputing. Call reset() before reusing the engine for a new computation.
Reference to the internal byte vector containing the digest.
std::string digestStr()Finalizes the digest computation and returns the result as a raw binary string (not hex-encoded). Use icy::hex::encode() on digest() if you need a printable representation.
Binary digest as a std::string.
void reset()Resets the digest context and clears the cached result, allowing the engine to be reused for a new computation with the same algorithm.
const
const std::string & algorithm() constReturns the algorithm name this engine was constructed with.
OpenSSL digest name string (e.g. "sha256").
| Return | Name | Description |
|---|---|---|
EvpMdCtxPtr | _ctx | |
const EVP_MD * | _md | |
crypto::ByteVec | _digest | |
std::string | _algorithm |
EvpMdCtxPtr _ctxconst EVP_MD * _mdcrypto::ByteVec _digeststd::string _algorithm