Fast RTPS  Version 2.14.1
Fast RTPS
Loading...
Searching...
No Matches
md5.h
1/* MD5
2 converted to C++ class by Frank Thilo (thilo@unix-ag.org)
3 for bzflag (http://www.bzflag.org)
4
5 based on:
6
7 md5.h and md5.c
8 reference implementation of RFC 1321
9
10 Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
11rights reserved.
12
13License to copy and use this software is granted provided that it
14is identified as the "RSA Data Security, Inc. MD5 Message-Digest
15Algorithm" in all material mentioning or referencing this software
16or this function.
17
18License is also granted to make and use derivative works provided
19that such works are identified as "derived from the RSA Data
20Security, Inc. MD5 Message-Digest Algorithm" in all material
21mentioning or referencing the derived work.
22
23RSA Data Security, Inc. makes no representations concerning either
24the merchantability of this software or the suitability of this
25software for any particular purpose. It is provided "as is"
26without express or implied warranty of any kind.
27
28These notices must be retained in any copies of any part of this
29documentation and/or software.
30
31*/
32
33#ifndef BZF_MD5_H
34#define BZF_MD5_H
35
36#include <cstring>
37#include <iostream>
38
39#include "../fastrtps_dll.h"
40
54class RTPS_DllAPI MD5
55{
56public:
57 typedef unsigned char uint1; // 8bit
58 typedef unsigned int size_type; // must be 32bit
59
60 MD5();
61 MD5(const std::string& text);
62 void update(const unsigned char *buf, size_type length);
63 void update(const char *buf, size_type length);
65 std::string hexdigest() const;
66 friend std::ostream& operator<<(std::ostream&, MD5& md5);
67 uint1 digest[16]; // the result
68
69 void init();
70private:
71
72
73 typedef unsigned int uint4; // 32bit
74 enum {blocksize = 64}; // VC6 won't eat a const static int here
75
76 void transform(const uint1 block[blocksize]);
77 static void decode(uint4 output[], const uint1 input[], size_type len);
78 static void encode(uint1 output[], const uint4 input[], size_type len);
79
80 bool finalized;
81 uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk
82 uint4 count[2]; // 64bit counter for number of bits (lo, hi)
83 uint4 state[4]; // digest so far
84
85
86 // low level logic operations
87 static inline uint4 F(uint4 x, uint4 y, uint4 z);
88 static inline uint4 G(uint4 x, uint4 y, uint4 z);
89 static inline uint4 H(uint4 x, uint4 y, uint4 z);
90 static inline uint4 I(uint4 x, uint4 y, uint4 z);
91 static inline uint4 rotate_left(uint4 x, int n);
92 static inline void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
93 static inline void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
94 static inline void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
95 static inline void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
96};
97
98std::string md5(const std::string str);
99
100#endif
101
Class MD5, for calculating MD5 hashes of strings or byte arrays it is not meant to be fast or secure.
Definition md5.h:55
unsigned char uint1
Definition md5.h:57
void init()
void update(const unsigned char *buf, size_type length)
MD5 & finalize()
void update(const char *buf, size_type length)
friend std::ostream & operator<<(std::ostream &, MD5 &md5)
MD5(const std::string &text)
unsigned int size_type
Definition md5.h:58
std::string hexdigest() const