18 #include <string_view>
20 #include "lhashes/lhashes_Export.h"
40 void update (
const unsigned char* data, std::size_t length)
final;
43 [[nodiscard]] std::string
getHash() final;
46 [[nodiscard]] std::
size_t getLengthOfHash() const final;
49 void transform (const
unsigned char* message,
unsigned block_nb) noexcept;
51 static constinit const
unsigned SHA224_256_BLOCK_SIZE = (512 / 8);
54 unsigned m_tot_len { 0 };
56 unsigned char m_block[2 * SHA224_256_BLOCK_SIZE] = {};
58 std::uint32_t m_h[8] = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 };
66 [[nodiscard]] LHASH_EXPORT std::string
sha256 (
const char* input, std::size_t length);
73 [[nodiscard]] LHASH_EXPORT std::string
sha256 (std::string_view input);
A base class representing an object that calculates a hash function.
A Hasher object that calculates a SHA256 hash.
void update(const unsigned char *data, std::size_t length) final
Updates the internal state of the hasher with new data.
std::string getHash() final
Retrieves the calculated SHA256 hash value as a string.
LHASH_EXPORT std::string sha256(const char *input, std::size_t length)
Calculates a SHA256 hash for the given data.
LHASH_EXPORT std::string sha256(std::string_view input)
Calculates a SHA256 hash for the given string.
This file defines the hash::Hasher class and the hash::hash() free functions.
Cryptographic hash functions.