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);
105 static inline void FF(
107 static inline void GG(
109 static inline void HH(
111 static inline void II(
138 return (
x &
y) | (~
x &
z);
143 return (
x &
z) | (
y & ~
z);
151 return (
x <<
n) | (
x >> (32 -
n));
159 a = rotate_left(
a + F(
b,
c, d) +
x + ac,
s) +
b;
165 a = rotate_left(
a +
G(
b,
c, d) +
x + ac,
s) +
b;
171 a = rotate_left(
a + H(
b,
c, d) +
x + ac,
s) +
b;
177 a = rotate_left(
a + I(
b,
c, d) +
x + ac,
s) +
b;
190 update(text.c_str(), text.length());
204 state[0] = 0x67452301;
205 state[1] = 0xefcdab89;
206 state[2] = 0x98badcfe;
207 state[3] = 0x10325476;
216 for (
unsigned int i = 0, j = 0; j <
len; i++, j += 4)
230 output[j] =
input[i] & 0xff;
231 output[j + 1] = (
input[i] >> 8) & 0xff;
232 output[j + 2] = (
input[i] >> 16) & 0xff;
233 output[j + 3] = (
input[i] >> 24) & 0xff;
242 uint4 a = state[0],
b = state[1],
c = state[2], d = state[3],
x[16];
243 decode(
x, block, blocksize);
246 FF(
a,
b,
c, d,
x[0],
S11, 0xd76aa478);
247 FF(d,
a,
b,
c,
x[1],
S12, 0xe8c7b756);
248 FF(
c, d,
a,
b,
x[2],
S13, 0x242070db);
249 FF(
b,
c, d,
a,
x[3],
S14, 0xc1bdceee);
250 FF(
a,
b,
c, d,
x[4],
S11, 0xf57c0faf);
251 FF(d,
a,
b,
c,
x[5],
S12, 0x4787c62a);
252 FF(
c, d,
a,
b,
x[6],
S13, 0xa8304613);
253 FF(
b,
c, d,
a,
x[7],
S14, 0xfd469501);
254 FF(
a,
b,
c, d,
x[8],
S11, 0x698098d8);
255 FF(d,
a,
b,
c,
x[9],
S12, 0x8b44f7af);
256 FF(
c, d,
a,
b,
x[10],
S13, 0xffff5bb1);
257 FF(
b,
c, d,
a,
x[11],
S14, 0x895cd7be);
258 FF(
a,
b,
c, d,
x[12],
S11, 0x6b901122);
259 FF(d,
a,
b,
c,
x[13],
S12, 0xfd987193);
260 FF(
c, d,
a,
b,
x[14],
S13, 0xa679438e);
261 FF(
b,
c, d,
a,
x[15],
S14, 0x49b40821);
264 GG(
a,
b,
c, d,
x[1],
S21, 0xf61e2562);
265 GG(d,
a,
b,
c,
x[6],
S22, 0xc040b340);
266 GG(
c, d,
a,
b,
x[11],
S23, 0x265e5a51);
267 GG(
b,
c, d,
a,
x[0],
S24, 0xe9b6c7aa);
268 GG(
a,
b,
c, d,
x[5],
S21, 0xd62f105d);
269 GG(d,
a,
b,
c,
x[10],
S22, 0x2441453);
270 GG(
c, d,
a,
b,
x[15],
S23, 0xd8a1e681);
271 GG(
b,
c, d,
a,
x[4],
S24, 0xe7d3fbc8);
272 GG(
a,
b,
c, d,
x[9],
S21, 0x21e1cde6);
273 GG(d,
a,
b,
c,
x[14],
S22, 0xc33707d6);
274 GG(
c, d,
a,
b,
x[3],
S23, 0xf4d50d87);
275 GG(
b,
c, d,
a,
x[8],
S24, 0x455a14ed);
276 GG(
a,
b,
c, d,
x[13],
S21, 0xa9e3e905);
277 GG(d,
a,
b,
c,
x[2],
S22, 0xfcefa3f8);
278 GG(
c, d,
a,
b,
x[7],
S23, 0x676f02d9);
279 GG(
b,
c, d,
a,
x[12],
S24, 0x8d2a4c8a);
282 HH(
a,
b,
c, d,
x[5],
S31, 0xfffa3942);
283 HH(d,
a,
b,
c,
x[8],
S32, 0x8771f681);
284 HH(
c, d,
a,
b,
x[11],
S33, 0x6d9d6122);
285 HH(
b,
c, d,
a,
x[14],
S34, 0xfde5380c);
286 HH(
a,
b,
c, d,
x[1],
S31, 0xa4beea44);
287 HH(d,
a,
b,
c,
x[4],
S32, 0x4bdecfa9);
288 HH(
c, d,
a,
b,
x[7],
S33, 0xf6bb4b60);
289 HH(
b,
c, d,
a,
x[10],
S34, 0xbebfbc70);
290 HH(
a,
b,
c, d,
x[13],
S31, 0x289b7ec6);
291 HH(d,
a,
b,
c,
x[0],
S32, 0xeaa127fa);
292 HH(
c, d,
a,
b,
x[3],
S33, 0xd4ef3085);
293 HH(
b,
c, d,
a,
x[6],
S34, 0x4881d05);
294 HH(
a,
b,
c, d,
x[9],
S31, 0xd9d4d039);
295 HH(d,
a,
b,
c,
x[12],
S32, 0xe6db99e5);
296 HH(
c, d,
a,
b,
x[15],
S33, 0x1fa27cf8);
297 HH(
b,
c, d,
a,
x[2],
S34, 0xc4ac5665);
300 II(
a,
b,
c, d,
x[0],
S41, 0xf4292244);
301 II(d,
a,
b,
c,
x[7],
S42, 0x432aff97);
302 II(
c, d,
a,
b,
x[14],
S43, 0xab9423a7);
303 II(
b,
c, d,
a,
x[5],
S44, 0xfc93a039);
304 II(
a,
b,
c, d,
x[12],
S41, 0x655b59c3);
305 II(d,
a,
b,
c,
x[3],
S42, 0x8f0ccc92);
306 II(
c, d,
a,
b,
x[10],
S43, 0xffeff47d);
307 II(
b,
c, d,
a,
x[1],
S44, 0x85845dd1);
308 II(
a,
b,
c, d,
x[8],
S41, 0x6fa87e4f);
309 II(d,
a,
b,
c,
x[15],
S42, 0xfe2ce6e0);
310 II(
c, d,
a,
b,
x[6],
S43, 0xa3014314);
311 II(
b,
c, d,
a,
x[13],
S44, 0x4e0811a1);
312 II(
a,
b,
c, d,
x[4],
S41, 0xf7537e82);
313 II(d,
a,
b,
c,
x[11],
S42, 0xbd3af235);
314 II(
c, d,
a,
b,
x[2],
S43, 0x2ad7d2bb);
315 II(
b,
c, d,
a,
x[9],
S44, 0xeb86d391);
323 memset(
x, 0,
sizeof x);
340 size_type firstpart = 64 -
index;
352 for (i = firstpart; i + blocksize <=
length; i += blocksize)
378 static unsigned char padding[64] = {
379 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
380 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
381 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
386 unsigned char bits[8];
387 encode(bits,
count, 8);
392 update(padding, padLen);
398 encode(digest, state, 16);
415 if (!finalized)
return "";
418 for (
int i = 0; i < 16; i++)
sprintf(buf + i * 2,
"%02x", digest[i]);
428 return out <<
md5.hexdigest();
436 return md5.hexdigest();
446 return md5.hexdigest();
GLuint GLuint GLsizei count
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)
GLsizei const GLchar ** string
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)
GLuint GLsizei GLsizei * length
GLenum GLenum GLenum input
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)
GLuint GLenum GLenum transform
unsigned __int32 uint32_t
GLsizei GLsizei GLenum GLenum const GLvoid * data
GLubyte GLubyte GLubyte a
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.