73 MD5(
const std::string& text);
74 void update(
const unsigned char* buf,
size_type length);
75 void update(
const char* buf,
size_type length);
77 std::string hexdigest()
const;
89 void transform(
const uint1 block[blocksize]);
90 static void decode(uint4 output[],
const uint1 input[], size_type len);
91 static void encode(uint1 output[],
const uint4 input[], size_type len);
93 bool finalized{
false};
98 uint4 state[4] = {0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476};
102 static inline uint4 F(uint4 x, uint4 y, uint4 z);
103 static inline uint4
G(uint4 x, uint4 y, uint4 z);
104 static inline uint4 H(uint4 x, uint4 y, uint4 z);
105 static inline uint4 I(uint4 x, uint4 y, uint4 z);
106 static inline uint4 rotate_left(uint4 x,
int n);
107 static inline void FF(
108 uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
109 static inline void GG(
110 uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
111 static inline void HH(
112 uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
113 static inline void II(
114 uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
140 return (x & y) | (~x & z);
145 return (x & z) | (y & ~z);
153 return (x << n) | (x >> (32 - n));
161 a = rotate_left(a + F(b, c, d) + x + ac, s) + b;
167 a = rotate_left(a +
G(b, c, d) + x + ac, s) + b;
173 a = rotate_left(a + H(b, c, d) + x + ac, s) + b;
179 a = rotate_left(a + I(b, c, d) + x + ac, s) + b;
188 update(text.c_str(), text.length());
202 for (
unsigned int i = 0, j = 0; j < len; i++, j += 4)
203 output[i] = ((
uint4)input[j]) | (((
uint4)input[j + 1]) << 8) |
204 (((
uint4)input[j + 2]) << 16) |
205 (((
uint4)input[j + 3]) << 24);
214 for (
size_type i = 0, j = 0; j < len; i++, j += 4)
216 output[j] = input[i] & 0xff;
217 output[j + 1] = (input[i] >> 8) & 0xff;
218 output[j + 2] = (input[i] >> 16) & 0xff;
219 output[j + 3] = (input[i] >> 24) & 0xff;
228 uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
229 decode(x, block, blocksize);
232 FF(a, b, c, d, x[0],
S11, 0xd76aa478);
233 FF(d, a, b, c, x[1],
S12, 0xe8c7b756);
234 FF(c, d, a, b, x[2],
S13, 0x242070db);
235 FF(b, c, d, a, x[3],
S14, 0xc1bdceee);
236 FF(a, b, c, d, x[4],
S11, 0xf57c0faf);
237 FF(d, a, b, c, x[5],
S12, 0x4787c62a);
238 FF(c, d, a, b, x[6],
S13, 0xa8304613);
239 FF(b, c, d, a, x[7],
S14, 0xfd469501);
240 FF(a, b, c, d, x[8],
S11, 0x698098d8);
241 FF(d, a, b, c, x[9],
S12, 0x8b44f7af);
242 FF(c, d, a, b, x[10],
S13, 0xffff5bb1);
243 FF(b, c, d, a, x[11],
S14, 0x895cd7be);
244 FF(a, b, c, d, x[12],
S11, 0x6b901122);
245 FF(d, a, b, c, x[13],
S12, 0xfd987193);
246 FF(c, d, a, b, x[14],
S13, 0xa679438e);
247 FF(b, c, d, a, x[15],
S14, 0x49b40821);
250 GG(a, b, c, d, x[1],
S21, 0xf61e2562);
251 GG(d, a, b, c, x[6],
S22, 0xc040b340);
252 GG(c, d, a, b, x[11],
S23, 0x265e5a51);
253 GG(b, c, d, a, x[0],
S24, 0xe9b6c7aa);
254 GG(a, b, c, d, x[5],
S21, 0xd62f105d);
255 GG(d, a, b, c, x[10],
S22, 0x2441453);
256 GG(c, d, a, b, x[15],
S23, 0xd8a1e681);
257 GG(b, c, d, a, x[4],
S24, 0xe7d3fbc8);
258 GG(a, b, c, d, x[9],
S21, 0x21e1cde6);
259 GG(d, a, b, c, x[14],
S22, 0xc33707d6);
260 GG(c, d, a, b, x[3],
S23, 0xf4d50d87);
261 GG(b, c, d, a, x[8],
S24, 0x455a14ed);
262 GG(a, b, c, d, x[13],
S21, 0xa9e3e905);
263 GG(d, a, b, c, x[2],
S22, 0xfcefa3f8);
264 GG(c, d, a, b, x[7],
S23, 0x676f02d9);
265 GG(b, c, d, a, x[12],
S24, 0x8d2a4c8a);
268 HH(a, b, c, d, x[5],
S31, 0xfffa3942);
269 HH(d, a, b, c, x[8],
S32, 0x8771f681);
270 HH(c, d, a, b, x[11],
S33, 0x6d9d6122);
271 HH(b, c, d, a, x[14],
S34, 0xfde5380c);
272 HH(a, b, c, d, x[1],
S31, 0xa4beea44);
273 HH(d, a, b, c, x[4],
S32, 0x4bdecfa9);
274 HH(c, d, a, b, x[7],
S33, 0xf6bb4b60);
275 HH(b, c, d, a, x[10],
S34, 0xbebfbc70);
276 HH(a, b, c, d, x[13],
S31, 0x289b7ec6);
277 HH(d, a, b, c, x[0],
S32, 0xeaa127fa);
278 HH(c, d, a, b, x[3],
S33, 0xd4ef3085);
279 HH(b, c, d, a, x[6],
S34, 0x4881d05);
280 HH(a, b, c, d, x[9],
S31, 0xd9d4d039);
281 HH(d, a, b, c, x[12],
S32, 0xe6db99e5);
282 HH(c, d, a, b, x[15],
S33, 0x1fa27cf8);
283 HH(b, c, d, a, x[2],
S34, 0xc4ac5665);
286 II(a, b, c, d, x[0],
S41, 0xf4292244);
287 II(d, a, b, c, x[7],
S42, 0x432aff97);
288 II(c, d, a, b, x[14],
S43, 0xab9423a7);
289 II(b, c, d, a, x[5],
S44, 0xfc93a039);
290 II(a, b, c, d, x[12],
S41, 0x655b59c3);
291 II(d, a, b, c, x[3],
S42, 0x8f0ccc92);
292 II(c, d, a, b, x[10],
S43, 0xffeff47d);
293 II(b, c, d, a, x[1],
S44, 0x85845dd1);
294 II(a, b, c, d, x[8],
S41, 0x6fa87e4f);
295 II(d, a, b, c, x[15],
S42, 0xfe2ce6e0);
296 II(c, d, a, b, x[6],
S43, 0xa3014314);
297 II(b, c, d, a, x[13],
S44, 0x4e0811a1);
298 II(a, b, c, d, x[4],
S41, 0xf7537e82);
299 II(d, a, b, c, x[11],
S42, 0xbd3af235);
300 II(c, d, a, b, x[2],
S43, 0x2ad7d2bb);
301 II(b, c, d, a, x[9],
S44, 0xeb86d391);
309 memset(x, 0,
sizeof x);
316 void MD5::update(
const unsigned char input[], size_type length)
319 size_type index = count[0] / 8 % blocksize;
322 if ((count[0] += (length << 3)) < (length << 3)) count[1]++;
323 count[1] += (length >> 29);
326 size_type firstpart = 64 - index;
331 if (length >= firstpart)
334 memcpy(&buffer[index], input, firstpart);
338 for (i = firstpart; i + blocksize <= length; i += blocksize)
339 transform(&input[i]);
347 memcpy(&buffer[index], &input[i], length - i);
353 void MD5::update(
const char input[], size_type length)
355 update(reinterpret_cast<const unsigned char*>(input), length);
364 static unsigned char padding[64] = {
365 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
366 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
367 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
372 unsigned char bits[8];
373 encode(bits, count, 8);
377 size_type padLen = (index < 56) ? (56 - index) : (120 - index);
378 update(padding, padLen);
384 encode(digest, state, 16);
387 memset(buffer, 0,
sizeof buffer);
388 memset(count, 0,
sizeof count);
401 if (!finalized)
return "";
404 for (
int i = 0; i < 16; i++)
sprintf(buf + i * 2,
"%02x", digest[i]);
407 return std::string(buf);
414 return out <<
md5.hexdigest();
422 return md5.hexdigest();
432 return md5.hexdigest();
std::ostream & operator<<(std::ostream &o, const TTimeStamp &t)
Textual representation of a TTimeStamp as the plain number in time_since_epoch().count() ...
void update(const unsigned char *buf, size_type length)
static void encode(uint1 output[], const uint4 input[], size_type len)
void transform(const uint1 block[blocksize])
#define ASSERT_(f)
Defines an assertion mechanism.
static uint4 G(uint4 x, uint4 y, uint4 z)
static void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
static void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
static void decode(uint4 output[], const uint1 input[], size_type len)
static uint4 H(uint4 x, uint4 y, uint4 z)
std::string hexdigest() const
static uint4 rotate_left(uint4 x, int n)
mrpt::vision::TStereoCalibResults out
static uint4 I(uint4 x, uint4 y, uint4 z)
static void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
static uint4 F(uint4 x, uint4 y, uint4 z)
int sprintf(char *buf, size_t bufSize, const char *format,...) noexcept MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...
static void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
void memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) noexcept
An OS and compiler independent version of "memcpy".
std::string md5(const std::string &str)
Computes the md5 of a block of data.
static struct FontData data