UtilsLite
Utilities for C++ programming
Loading...
Searching...
No Matches
Utils::SHA3 Class Reference

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.
 

Detailed Description

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.

Author
Christopher Bentivenga
Frederick Christie
Michael Kitson

Ported to C++ by Enrico Bertolazzi

Constructor & Destructor Documentation

◆ SHA3()

Utils::SHA3::SHA3 ( int digest_size)
explicit

Constructor for the SHA3 class.

Initializes the SHA3 hashing algorithm with the specified digest size.

Parameters
digest_sizeThe size of the desired hash output in bytes (e.g., 224, 256, 384, or 512).

◆ ~SHA3()

Utils::SHA3::~SHA3 ( )
inline

Destructor for the SHA3 class.

Member Function Documentation

◆ digest()

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.

Parameters
dPointer to the byte array where the digest will be stored.

◆ digest_in_hex()

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.

Returns
The hexadecimal string representation of the hash digest.

◆ digest_size()

int Utils::SHA3::digest_size ( ) const
inline

Returns the size of the hash digest.

This method returns the size of the hash output in bytes.

Returns
The size of the digest in bytes.

◆ hash()

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.

Parameters
bThe number of bytes to hash.

◆ hash_hex_string()

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.

Parameters
strThe null-terminated hexadecimal string of bytes to add to the hash.

◆ hash_string()

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.

Parameters
strThe null-terminated string of bytes to add to the hash.

The documentation for this class was generated from the following files: