Hash
Hash
#include <icy/crypto/hash.h>class HashDefined in src/crypto/include/icy/crypto/hash.h:38
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.
List of all members
| Name | Kind | Owner |
|---|---|---|
Hash | function | Declared here |
~Hash | function | Declared here |
update | function | Declared here |
update | function | Declared here |
update | function | Declared here |
digest | function | Declared here |
digestStr | function | Declared here |
reset | function | Declared here |
algorithm | function | Declared here |
_ctx | variable | Declared here |
_md | variable | Declared here |
_digest | variable | Declared here |
_algorithm | variable | Declared here |
operator= | function | Declared here |
Public Methods
| 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
Hash(const std::string & algorithm)Defined in src/crypto/include/icy/crypto/hash.h:45
Constructs a Hash engine for the given algorithm.
Parameters
algorithmOpenSSL digest name (e.g. "sha256", "sha1", "md5").
Exceptions
std::runtime_errorif the algorithm is not recognized by OpenSSL.
~Hash
~Hash()Defined in src/crypto/include/icy/crypto/hash.h:48
Destroys the Hash engine and releases OpenSSL resources.
update
void update(char data)Defined in src/crypto/include/icy/crypto/hash.h:53
Feeds a single character into the digest computation.
Parameters
dataThe byte to hash.
update
void update(std::string_view data)Defined in src/crypto/include/icy/crypto/hash.h:58
Feeds a string view into the digest computation.
Parameters
dataThe data to hash.
update
void update(const void * data, size_t length)Defined in src/crypto/include/icy/crypto/hash.h:66
Feeds a raw memory buffer into the digest computation.
This method may be called multiple times for streaming large inputs.
Parameters
dataPointer to the input buffer.lengthNumber of bytes to hash fromdata.
digest
const ByteVec & digest()Defined in src/crypto/include/icy/crypto/hash.h:75
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.
Returns
Reference to the internal byte vector containing the digest.
digestStr
std::string digestStr()Defined in src/crypto/include/icy/crypto/hash.h:82
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.
Returns
Binary digest as a std::string.
reset
void reset()Defined in src/crypto/include/icy/crypto/hash.h:86
Resets the digest context and clears the cached result, allowing the engine to be reused for a new computation with the same algorithm.
algorithm
const
const std::string & algorithm() constDefined in src/crypto/include/icy/crypto/hash.h:91
Returns the algorithm name this engine was constructed with.
Returns
OpenSSL digest name string (e.g. "sha256").
Protected Attributes
| Return | Name | Description |
|---|---|---|
EvpMdCtxPtr | _ctx | |
const EVP_MD * | _md | |
crypto::ByteVec | _digest | |
std::string | _algorithm |
_ctx
EvpMdCtxPtr _ctxDefined in src/crypto/include/icy/crypto/hash.h:96
_md
const EVP_MD * _mdDefined in src/crypto/include/icy/crypto/hash.h:97
_digest
crypto::ByteVec _digestDefined in src/crypto/include/icy/crypto/hash.h:98
_algorithm
std::string _algorithm