83 enum {blocksize = 64};
85 void transform(
const uint1 block[blocksize]);
86 static void decode(uint4 output[],
const uint1
input[], size_type
len);
87 static void encode(uint1 output[],
const uint4
input[], size_type
len);
131 return (
x&
y) | (~
x&
z);
135 return (
x&
z) | (
y&~
z);
148 return (
x <<
n) | (
x >> (32-
n));
154 a = rotate_left(
a+ F(
b,
c,d) +
x + ac,
s) +
b;
158 a = rotate_left(
a + G(
b,
c,d) +
x + ac,
s) +
b;
162 a = rotate_left(
a + H(
b,
c,d) +
x + ac,
s) +
b;
166 a = rotate_left(
a + I(
b,
c,d) +
x + ac,
s) +
b;
183 update(text.c_str(), text.length());
197 state[0] = 0x67452301;
198 state[1] = 0xefcdab89;
199 state[2] = 0x98badcfe;
200 state[3] = 0x10325476;
208 for (
unsigned int i = 0, j = 0; j <
len; i++, j += 4)
220 output[j] =
input[i] & 0xff;
221 output[j+1] = (
input[i] >> 8) & 0xff;
222 output[j+2] = (
input[i] >> 16) & 0xff;
223 output[j+3] = (
input[i] >> 24) & 0xff;
232 uint4 a = state[0],
b = state[1],
c = state[2], d = state[3],
x[16];
233 decode (
x, block, blocksize);
236 FF (
a,
b,
c, d,
x[ 0],
S11, 0xd76aa478);
237 FF (d,
a,
b,
c,
x[ 1],
S12, 0xe8c7b756);
238 FF (
c, d,
a,
b,
x[ 2],
S13, 0x242070db);
239 FF (
b,
c, d,
a,
x[ 3],
S14, 0xc1bdceee);
240 FF (
a,
b,
c, d,
x[ 4],
S11, 0xf57c0faf);
241 FF (d,
a,
b,
c,
x[ 5],
S12, 0x4787c62a);
242 FF (
c, d,
a,
b,
x[ 6],
S13, 0xa8304613);
243 FF (
b,
c, d,
a,
x[ 7],
S14, 0xfd469501);
244 FF (
a,
b,
c, d,
x[ 8],
S11, 0x698098d8);
245 FF (d,
a,
b,
c,
x[ 9],
S12, 0x8b44f7af);
246 FF (
c, d,
a,
b,
x[10],
S13, 0xffff5bb1);
247 FF (
b,
c, d,
a,
x[11],
S14, 0x895cd7be);
248 FF (
a,
b,
c, d,
x[12],
S11, 0x6b901122);
249 FF (d,
a,
b,
c,
x[13],
S12, 0xfd987193);
250 FF (
c, d,
a,
b,
x[14],
S13, 0xa679438e);
251 FF (
b,
c, d,
a,
x[15],
S14, 0x49b40821);
254 GG (
a,
b,
c, d,
x[ 1],
S21, 0xf61e2562);
255 GG (d,
a,
b,
c,
x[ 6],
S22, 0xc040b340);
256 GG (
c, d,
a,
b,
x[11],
S23, 0x265e5a51);
257 GG (
b,
c, d,
a,
x[ 0],
S24, 0xe9b6c7aa);
258 GG (
a,
b,
c, d,
x[ 5],
S21, 0xd62f105d);
259 GG (d,
a,
b,
c,
x[10],
S22, 0x2441453);
260 GG (
c, d,
a,
b,
x[15],
S23, 0xd8a1e681);
261 GG (
b,
c, d,
a,
x[ 4],
S24, 0xe7d3fbc8);
262 GG (
a,
b,
c, d,
x[ 9],
S21, 0x21e1cde6);
263 GG (d,
a,
b,
c,
x[14],
S22, 0xc33707d6);
264 GG (
c, d,
a,
b,
x[ 3],
S23, 0xf4d50d87);
265 GG (
b,
c, d,
a,
x[ 8],
S24, 0x455a14ed);
266 GG (
a,
b,
c, d,
x[13],
S21, 0xa9e3e905);
267 GG (d,
a,
b,
c,
x[ 2],
S22, 0xfcefa3f8);
268 GG (
c, d,
a,
b,
x[ 7],
S23, 0x676f02d9);
269 GG (
b,
c, d,
a,
x[12],
S24, 0x8d2a4c8a);
272 HH (
a,
b,
c, d,
x[ 5],
S31, 0xfffa3942);
273 HH (d,
a,
b,
c,
x[ 8],
S32, 0x8771f681);
274 HH (
c, d,
a,
b,
x[11],
S33, 0x6d9d6122);
275 HH (
b,
c, d,
a,
x[14],
S34, 0xfde5380c);
276 HH (
a,
b,
c, d,
x[ 1],
S31, 0xa4beea44);
277 HH (d,
a,
b,
c,
x[ 4],
S32, 0x4bdecfa9);
278 HH (
c, d,
a,
b,
x[ 7],
S33, 0xf6bb4b60);
279 HH (
b,
c, d,
a,
x[10],
S34, 0xbebfbc70);
280 HH (
a,
b,
c, d,
x[13],
S31, 0x289b7ec6);
281 HH (d,
a,
b,
c,
x[ 0],
S32, 0xeaa127fa);
282 HH (
c, d,
a,
b,
x[ 3],
S33, 0xd4ef3085);
283 HH (
b,
c, d,
a,
x[ 6],
S34, 0x4881d05);
284 HH (
a,
b,
c, d,
x[ 9],
S31, 0xd9d4d039);
285 HH (d,
a,
b,
c,
x[12],
S32, 0xe6db99e5);
286 HH (
c, d,
a,
b,
x[15],
S33, 0x1fa27cf8);
287 HH (
b,
c, d,
a,
x[ 2],
S34, 0xc4ac5665);
290 II (
a,
b,
c, d,
x[ 0],
S41, 0xf4292244);
291 II (d,
a,
b,
c,
x[ 7],
S42, 0x432aff97);
292 II (
c, d,
a,
b,
x[14],
S43, 0xab9423a7);
293 II (
b,
c, d,
a,
x[ 5],
S44, 0xfc93a039);
294 II (
a,
b,
c, d,
x[12],
S41, 0x655b59c3);
295 II (d,
a,
b,
c,
x[ 3],
S42, 0x8f0ccc92);
296 II (
c, d,
a,
b,
x[10],
S43, 0xffeff47d);
297 II (
b,
c, d,
a,
x[ 1],
S44, 0x85845dd1);
298 II (
a,
b,
c, d,
x[ 8],
S41, 0x6fa87e4f);
299 II (d,
a,
b,
c,
x[15],
S42, 0xfe2ce6e0);
300 II (
c, d,
a,
b,
x[ 6],
S43, 0xa3014314);
301 II (
b,
c, d,
a,
x[13],
S44, 0x4e0811a1);
302 II (
a,
b,
c, d,
x[ 4],
S41, 0xf7537e82);
303 II (d,
a,
b,
c,
x[11],
S42, 0xbd3af235);
304 II (
c, d,
a,
b,
x[ 2],
S43, 0x2ad7d2bb);
305 II (
b,
c, d,
a,
x[ 9],
S44, 0xeb86d391);
313 memset(
x, 0,
sizeof x);
331 size_type firstpart = 64 -
index;
343 for (i = firstpart; i + blocksize <=
length; i += blocksize)
369 static unsigned char padding[64] = {
370 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
371 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
372 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
377 unsigned char bits[8];
378 encode(bits,
count, 8);
383 update(padding, padLen);
389 encode(digest, state, 16);
410 for (
int i=0; i<16; i++)
411 sprintf(buf+i*2,
"%02x", digest[i]);
421 return out <<
md5.hexdigest();
429 return md5.hexdigest();
439 return md5.hexdigest();
void BASE_IMPEXP memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) MRPT_NO_THROWS
An OS and compiler independent version of "memcpy".
GLuint GLuint GLsizei count
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
std::string BASE_IMPEXP md5(const std::string &str)
Computes the md5 of a block of data.
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])
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)
CStream BASE_IMPEXP & operator<<(mrpt::utils::CStream &s, const char *a)
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)
int BASE_IMPEXP sprintf(char *buf, size_t bufSize, const char *format,...) MRPT_NO_THROWS MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...
std::vector< uint8_t > vector_byte
GLuint GLenum GLenum transform
GLsizei GLsizei GLenum GLenum const GLvoid * data
GLubyte GLubyte GLubyte a
static uint4 F(uint4 x, uint4 y, uint4 z)
static void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)