![]() |
UtilsLite
Utilities for C++ programming
|
SHA-3 winning hash algorithm Keccak. More...
#include <Utils_SHA3.hh>
Public Member Functions | |
SHA3 (int digest_size) | |
Constructor for the SHA3 class. | |
~SHA3 () | |
Destructor for the SHA3 class. | |
void | hash_string (string_view str) |
Adds an entire string to the message. | |
void | hash_hex_string (string_view str) |
Adds an entire hexadecimal string to the message. | |
string | digest_in_hex () |
Returns a representation of the digest as a hexadecimal string. | |
int | digest_size () const |
Returns the size of the hash digest. | |
void | hash (const int b) |
Hash a specified number of bytes. | |
void | digest (uint8_t *d) |
Retrieve the digest and store it in the provided byte array. | |
SHA-3 winning hash algorithm Keccak.
This class implements the SHA-3 hashing algorithm, based on the Keccak design. It provides methods to compute the hash of strings and returns the hash digest in hexadecimal format.
Ported to C++ by Enrico Bertolazzi
|
explicit |
|
inline |
Destructor for the SHA3 class.
void Utils::SHA3::digest | ( | uint8_t * | d | ) |
Retrieve the digest and store it in the provided byte array.
This method finalizes the hashing process and stores the resulting hash digest in the provided byte array.
d | Pointer to the byte array where the digest will be stored. |
string Utils::SHA3::digest_in_hex | ( | ) |
Returns a representation of the digest as a hexadecimal string.
This method finalizes the hashing process and returns the resulting hash digest as a hexadecimal string. The caller takes ownership of the returned string.
|
inline |
Returns the size of the hash digest.
This method returns the size of the hash output in bytes.
void Utils::SHA3::hash | ( | const int | b | ) |
Hash a specified number of bytes.
This method processes the provided byte input to update the hash state.
b | The number of bytes to hash. |
void Utils::SHA3::hash_hex_string | ( | string_view | str | ) |
Adds an entire hexadecimal string to the message.
This method appends the given hexadecimal string to the internal message buffer. Each pair of hex digits is converted to a byte.
str | The null-terminated hexadecimal string of bytes to add to the hash. |
void Utils::SHA3::hash_string | ( | string_view | str | ) |
Adds an entire string to the message.
This method appends the given string to the internal message buffer for hashing. It processes the string as a sequence of bytes.
str | The null-terminated string of bytes to add to the hash. |