Lightweight 0.20260303.0
Loading...
Searching...
No Matches
Lightweight::SqlBackup::Sha256 Class Reference

Simple SHA-256 implementation for backup integrity verification. More...

#include <Sha256.hpp>

Public Member Functions

void Reset ()
 Resets the hash state to initial values.
 
void Update (void const *data, size_t len)
 Updates the hash with the given data.
 
void Update (std::span< uint8_t const > data)
 Updates the hash with the given data span.
 
void Update (std::string_view data)
 Updates the hash with the given string data.
 
std::array< uint8_t, DigestSizeFinalize ()
 Finalizes the hash computation and returns the digest.
 

Static Public Member Functions

static std::string ToHex (std::array< uint8_t, DigestSize > const &digest)
 Converts a digest to its hexadecimal string representation.
 
static std::string Hash (void const *data, size_t len)
 Computes the SHA-256 hash of the given data and returns it as a hex string.
 
static std::string Hash (std::string_view data)
 Computes the SHA-256 hash of the given string and returns it as a hex string.
 

Static Public Attributes

static constexpr size_t DigestSize = 32
 The size of the SHA-256 digest in bytes.
 
static constexpr size_t BlockSize = 64
 The block size used by the SHA-256 algorithm in bytes.
 

Detailed Description

Simple SHA-256 implementation for backup integrity verification.

Definition at line 17 of file Sha256.hpp.

Constructor & Destructor Documentation

◆ Sha256()

Lightweight::SqlBackup::Sha256::Sha256 ( )
inline

Definition at line 25 of file Sha256.hpp.

Member Function Documentation

◆ Reset()

void Lightweight::SqlBackup::Sha256::Reset ( )
inline

Resets the hash state to initial values.

Definition at line 31 of file Sha256.hpp.

◆ Update() [1/3]

void Lightweight::SqlBackup::Sha256::Update ( void const *  data,
size_t  len 
)
inline

Updates the hash with the given data.

Definition at line 46 of file Sha256.hpp.

References BlockSize.

Referenced by Finalize(), Hash(), Update(), and Update().

◆ Update() [2/3]

void Lightweight::SqlBackup::Sha256::Update ( std::span< uint8_t const >  data)
inline

Updates the hash with the given data span.

Definition at line 81 of file Sha256.hpp.

References Update().

◆ Update() [3/3]

void Lightweight::SqlBackup::Sha256::Update ( std::string_view  data)
inline

Updates the hash with the given string data.

Definition at line 87 of file Sha256.hpp.

References Update().

◆ Finalize()

std::array< uint8_t, DigestSize > Lightweight::SqlBackup::Sha256::Finalize ( )
inline

Finalizes the hash computation and returns the digest.

Definition at line 93 of file Sha256.hpp.

References Update().

Referenced by Hash().

◆ ToHex()

static std::string Lightweight::SqlBackup::Sha256::ToHex ( std::array< uint8_t, DigestSize > const &  digest)
inlinestatic

Converts a digest to its hexadecimal string representation.

Definition at line 126 of file Sha256.hpp.

Referenced by Hash().

◆ Hash() [1/2]

static std::string Lightweight::SqlBackup::Sha256::Hash ( void const *  data,
size_t  len 
)
inlinestatic

Computes the SHA-256 hash of the given data and returns it as a hex string.

Definition at line 135 of file Sha256.hpp.

References Finalize(), ToHex(), and Update().

Referenced by Hash().

◆ Hash() [2/2]

static std::string Lightweight::SqlBackup::Sha256::Hash ( std::string_view  data)
inlinestatic

Computes the SHA-256 hash of the given string and returns it as a hex string.

Definition at line 143 of file Sha256.hpp.

References Hash().

Member Data Documentation

◆ DigestSize

constexpr size_t Lightweight::SqlBackup::Sha256::DigestSize = 32
staticconstexpr

The size of the SHA-256 digest in bytes.

Definition at line 21 of file Sha256.hpp.

◆ BlockSize

constexpr size_t Lightweight::SqlBackup::Sha256::BlockSize = 64
staticconstexpr

The block size used by the SHA-256 algorithm in bytes.

Definition at line 23 of file Sha256.hpp.

Referenced by Update().


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