KiCad PCB EDA Suite
Loading...
Searching...
No Matches
md5_hash.h
Go to the documentation of this file.
1// Code by: B-Con (http://b-con.us)
2// Released under the GNU GPL
3// MD5 Hash Digest implementation (little endian byte order)
4
5#ifndef __MD5_HASH_H
6#define __MD5_HASH_H
7
8#include <cstdint>
9#include <string>
10
12{
13
14public:
15 MD5_HASH();
16 MD5_HASH( const MD5_HASH& aOther );
17
18 ~MD5_HASH();
19
20 void Init();
21 void Hash ( uint8_t *data, uint32_t length );
22 void Hash ( int value );
23 void Finalize();
24 bool IsValid() const { return m_valid; };
25
26 void SetValid( bool aValid ) { m_valid = aValid; }
27
28 MD5_HASH& operator=( const MD5_HASH& aOther );
29
30 bool operator==( const MD5_HASH& aOther ) const;
31 bool operator!=( const MD5_HASH& aOther ) const;
32
38 std::string Format( bool aCompactForm = false );
39
40private:
41 struct MD5_CTX {
42 uint8_t data[64];
43 uint32_t datalen;
44 uint32_t bitlen[2];
45 uint32_t state[4];
46 };
47
48 void md5_transform(MD5_CTX *ctx, uint8_t data[]);
49 void md5_init(MD5_CTX *ctx);
50 void md5_update(MD5_CTX *ctx, uint8_t data[], uint32_t len);
51 void md5_final(MD5_CTX *ctx, uint8_t hash[]);
52
53 bool m_valid;
55 uint8_t m_hash[16];
56};
57
58#endif
void md5_transform(MD5_CTX *ctx, uint8_t data[])
Definition: md5_hash.cpp:125
void Finalize()
Definition: md5_hash.cpp:78
void Hash(uint8_t *data, uint32_t length)
Definition: md5_hash.cpp:66
~MD5_HASH()
Definition: md5_hash.cpp:44
void Init()
Definition: md5_hash.cpp:58
bool m_valid
Definition: md5_hash.h:53
std::string Format(bool aCompactForm=false)
Definition: md5_hash.cpp:97
void md5_final(MD5_CTX *ctx, uint8_t hash[])
Definition: md5_hash.cpp:245
MD5_HASH & operator=(const MD5_HASH &aOther)
Definition: md5_hash.cpp:48
void md5_update(MD5_CTX *ctx, uint8_t data[], uint32_t len)
Definition: md5_hash.cpp:228
void md5_init(MD5_CTX *ctx)
Definition: md5_hash.cpp:215
uint8_t m_hash[16]
Definition: md5_hash.h:55
MD5_HASH()
Definition: md5_hash.cpp:30
bool IsValid() const
Definition: md5_hash.h:24
void SetValid(bool aValid)
Definition: md5_hash.h:26
MD5_CTX m_ctx
Definition: md5_hash.h:54
bool operator!=(const MD5_HASH &aOther) const
Definition: md5_hash.cpp:91
bool operator==(const MD5_HASH &aOther) const
Definition: md5_hash.cpp:85
uint8_t data[64]
Definition: md5_hash.h:42
uint32_t datalen
Definition: md5_hash.h:43
uint32_t bitlen[2]
Definition: md5_hash.h:44
uint32_t state[4]
Definition: md5_hash.h:45