ESPHome 2025.10.0-dev
Loading...
Searching...
No Matches
md5.h
Go to the documentation of this file.
1#pragma once
2
4#ifdef USE_MD5
5
7
8#ifdef USE_ESP32
9#include "esp_rom_md5.h"
10#define MD5_CTX_TYPE md5_context_t
11#endif
12
13#if defined(USE_ARDUINO) && defined(USE_ESP8266)
14#include <md5.h>
15#define MD5_CTX_TYPE md5_context_t
16#endif
17
18#ifdef USE_RP2040
19#include <MD5Builder.h>
20#define MD5_CTX_TYPE br_md5_context
21#endif
22
23#if defined(USE_LIBRETINY)
24#include <MD5.h>
25#define MD5_CTX_TYPE LT_MD5_CTX_T
26#endif
27
28namespace esphome {
29namespace md5 {
30
31class MD5Digest : public HashBase {
32 public:
33 MD5Digest() = default;
34 ~MD5Digest() override = default;
35
37 void init() override;
38
40 void add(const uint8_t *data, size_t len) override;
41 using HashBase::add; // Bring base class overload into scope
42
44 void calculate() override;
45
47 size_t get_size() const override { return 16; }
48
49 protected:
50 MD5_CTX_TYPE ctx_{};
51};
52
53} // namespace md5
54} // namespace esphome
55#endif
Base class for hash algorithms.
Definition hash_base.h:11
virtual void add(const uint8_t *data, size_t len)=0
Add bytes of data for the hash.
void calculate() override
Compute the digest, based on the provided data.
Definition md5.cpp:17
size_t get_size() const override
Get the size of the hash in bytes (16 for MD5)
Definition md5.h:47
~MD5Digest() override=default
void add(const uint8_t *data, size_t len) override
Add bytes of data for the digest.
Definition md5.cpp:15
void init() override
Initialize a new MD5 digest computation.
Definition md5.cpp:10
MD5_CTX_TYPE ctx_
Definition md5.h:50
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
std::string size_t len
Definition helpers.h:291