arduino-emulator
Loading...
Searching...
No Matches
MD5Builder.h
1/*
2 MD5Builder - Simple MD5 hash calculations
3
4 Updated for the Pico by Earle F. Philhower, III
5 Updated for Linux by Mitch Bradley
6
7 Modified from the ESP8266 version which is
8 Copyright (c) 2015 Hristo Gochkov. All rights reserved.
9 This file is part of the esp8266 core for Arduino environment.
10
11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Lesser General Public
13 License as published by the Free Software Foundation; either
14 version 2.1 of the License, or (at your option) any later version.
15
16 This library is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Lesser General Public License for more details.
20
21 You should have received a copy of the GNU Lesser General Public
22 License along with this library; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#pragma once
27
28#include <api/String.h>
29#include <Stream.h>
30#include <cstring>
31
33private:
34 uint64_t _size; // Size of input in bytes
35 uint32_t _buffer[4]; // Current accumulation of hash
36 uint8_t _input[64]; // Input to be used in the next step
37 uint8_t _digest[16]; // Result of algorithm
38public:
39 void begin(void);
40 void add(const uint8_t * data, const size_t len);
41 void add(const char * data) {
42 add((const uint8_t*)data, strlen(data));
43 }
44 void add(char * data) {
45 add((const char*)data);
46 }
47 void add(const String& data) {
48 add(data.c_str());
49 }
50 void addHexString(const char * data);
51 void addHexString(char * data) {
52 addHexString((const char*)data);
53 }
54 void addHexString(const String& data) {
55 addHexString(data.c_str());
56 }
57 bool addStream(Stream & stream, const size_t maxLen);
58 void calculate(void);
59 void getBytes(uint8_t * output) const;
60 void getChars(char * output) const;
61 String toString(void) const;
62};
Definition MD5Builder.h:32