ESPHome 2025.5.0
Loading...
Searching...
No Matches
hmac_md5.h
Go to the documentation of this file.
1#pragma once
2
4#ifdef USE_MD5
6#include <string>
7
8namespace esphome {
9namespace hmac_md5 {
10
11class HmacMD5 {
12 public:
13 HmacMD5() = default;
14 ~HmacMD5() = default;
15
17 void init(const uint8_t *key, size_t len);
18 void init(const char *key, size_t len) { this->init((const uint8_t *) key, len); }
19 void init(const std::string &key) { this->init(key.c_str(), key.length()); }
20
22 void add(const uint8_t *data, size_t len);
23 void add(const char *data, size_t len) { this->add((const uint8_t *) data, len); }
24
26 void calculate();
27
30 void get_bytes(uint8_t *output);
31
34 void get_hex(char *output);
35
37 bool equals_bytes(const uint8_t *expected);
38
40 bool equals_hex(const char *expected);
41
42 protected:
45};
46
47} // namespace hmac_md5
48} // namespace esphome
49#endif
bool equals_hex(const char *expected)
Compare the digest against a provided hex-encoded digest (32 bytes).
Definition hmac_md5.cpp:54
void init(const char *key, size_t len)
Definition hmac_md5.h:18
void calculate()
Compute the digest, based on the provided data.
Definition hmac_md5.cpp:38
void init(const std::string &key)
Definition hmac_md5.h:19
void add(const char *data, size_t len)
Definition hmac_md5.h:23
md5::MD5Digest ihash_
Definition hmac_md5.h:43
md5::MD5Digest ohash_
Definition hmac_md5.h:44
void get_hex(char *output)
Retrieve the HMAC-MD5 digest as hex characters.
Definition hmac_md5.cpp:50
void add(const uint8_t *data, size_t len)
Add bytes of data for the digest.
Definition hmac_md5.cpp:36
bool equals_bytes(const uint8_t *expected)
Compare the digest against a provided byte-encoded digest (16 bytes).
Definition hmac_md5.cpp:52
void get_bytes(uint8_t *output)
Retrieve the HMAC-MD5 digest as bytes.
Definition hmac_md5.cpp:48
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
std::string size_t len
Definition helpers.h:301
void init()
Definition core.cpp:90