ESPHome 2025.10.0-dev
Loading...
Searching...
No Matches
esphome::HashBase Class Referenceabstract

Base class for hash algorithms. More...

#include <hash_base.h>

Inheritance diagram for esphome::HashBase:
esphome::md5::MD5Digest esphome::sha256::SHA256

Public Member Functions

virtual ~HashBase ()=default
 
virtual void init ()=0
 Initialize a new hash computation.
 
virtual void add (const uint8_t *data, size_t len)=0
 Add bytes of data for the hash.
 
void add (const char *data, size_t len)
 
virtual void calculate ()=0
 Compute the hash based on provided data.
 
void get_bytes (uint8_t *output)
 Retrieve the hash as bytes.
 
void get_hex (char *output)
 Retrieve the hash as hex characters.
 
bool equals_bytes (const uint8_t *expected)
 Compare the hash against a provided byte-encoded hash.
 
bool equals_hex (const char *expected)
 Compare the hash against a provided hex-encoded hash.
 
virtual size_t get_size () const =0
 Get the size of the hash in bytes (16 for MD5, 32 for SHA256)
 

Protected Attributes

uint8_t digest_ [32]
 

Detailed Description

Base class for hash algorithms.

Definition at line 11 of file hash_base.h.

Constructor & Destructor Documentation

◆ ~HashBase()

virtual esphome::HashBase::~HashBase ( )
virtualdefault

Member Function Documentation

◆ add() [1/2]

void esphome::HashBase::add ( const char * data,
size_t len )
inline

Definition at line 20 of file hash_base.h.

◆ add() [2/2]

virtual void esphome::HashBase::add ( const uint8_t * data,
size_t len )
pure virtual

Add bytes of data for the hash.

Implemented in esphome::md5::MD5Digest, and esphome::sha256::SHA256.

◆ calculate()

virtual void esphome::HashBase::calculate ( )
pure virtual

Compute the hash based on provided data.

Implemented in esphome::md5::MD5Digest, and esphome::sha256::SHA256.

◆ equals_bytes()

bool esphome::HashBase::equals_bytes ( const uint8_t * expected)
inline

Compare the hash against a provided byte-encoded hash.

Definition at line 38 of file hash_base.h.

◆ equals_hex()

bool esphome::HashBase::equals_hex ( const char * expected)
inline

Compare the hash against a provided hex-encoded hash.

Definition at line 41 of file hash_base.h.

◆ get_bytes()

void esphome::HashBase::get_bytes ( uint8_t * output)
inline

Retrieve the hash as bytes.

Definition at line 26 of file hash_base.h.

◆ get_hex()

void esphome::HashBase::get_hex ( char * output)
inline

Retrieve the hash as hex characters.

Definition at line 29 of file hash_base.h.

◆ get_size()

virtual size_t esphome::HashBase::get_size ( ) const
pure virtual

Get the size of the hash in bytes (16 for MD5, 32 for SHA256)

Implemented in esphome::md5::MD5Digest, and esphome::sha256::SHA256.

◆ init()

virtual void esphome::HashBase::init ( )
pure virtual

Initialize a new hash computation.

Implemented in esphome::md5::MD5Digest, and esphome::sha256::SHA256.

Field Documentation

◆ digest_

uint8_t esphome::HashBase::digest_[32]
protected

Definition at line 53 of file hash_base.h.


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