ESPHome 2026.1.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_HOST
9#include <openssl/evp.h>
10#endif
11
12#ifdef USE_ESP32
13#include "esp_rom_md5.h"
14#define MD5_CTX_TYPE md5_context_t
15#endif
16
17#if defined(USE_ARDUINO) && defined(USE_ESP8266)
18#include <md5.h>
19#define MD5_CTX_TYPE md5_context_t
20#endif
21
22#ifdef USE_RP2040
23#include <MD5Builder.h>
24#define MD5_CTX_TYPE br_md5_context
25#endif
26
27#if defined(USE_LIBRETINY)
28#include <MD5.h>
29#define MD5_CTX_TYPE LT_MD5_CTX_T
30#endif
31
32namespace esphome {
33namespace md5 {
34
35class MD5Digest : public HashBase {
36 public:
37 MD5Digest() = default;
38 ~MD5Digest() override;
39
41 void init() override;
42
44 void add(const uint8_t *data, size_t len) override;
45 using HashBase::add; // Bring base class overload into scope
46
48 void calculate() override;
49
51 size_t get_size() const override { return 16; }
52
53 protected:
54#ifdef USE_HOST
55 EVP_MD_CTX *ctx_{nullptr};
56 bool calculated_{false};
57#else
58 MD5_CTX_TYPE ctx_{};
59#endif
60};
61
62} // namespace md5
63} // namespace esphome
64#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
EVP_MD_CTX * ctx_
Definition md5.h:55
size_t get_size() const override
Get the size of the hash in bytes (16 for MD5)
Definition md5.h:51
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
~MD5Digest() override
Definition md5.cpp:43
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
std::string size_t len
Definition helpers.h:533