28 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476
32 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
33 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
34 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
35 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21
39 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
40 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
41 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
42 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
43 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
44 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
45 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
46 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
47 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
48 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
49 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
50 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
51 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
52 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
53 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
54 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
58 0x00000080, 0x00000000, 0x00000000, 0x00000000,
59 0x00000000, 0x00000000, 0x00000000, 0x00000000,
60 0x00000000, 0x00000000, 0x00000000, 0x00000000,
61 0x00000000, 0x00000000, 0x00000000, 0x00000000
88 this->numDigestedBits.data());
89 size_t i = this->numDigestedBits.size()*
sizeof(uint32_t)-
sizeof(
size_t);
91 return *
reinterpret_cast<const size_t*
>(&numDigestedBits[i]);
99 finalize(digest, numDigestedBits, buffer);
110 update(reinterpret_cast<const uint8_t*>(text.data()), text.length());
131 char stringData[2*digest.size()*
sizeof(uint32_t)+1];
132 const uint8_t* digestData =
reinterpret_cast<const uint8_t*
>(
135 for (
size_t i = 0; i < digest.size()*
sizeof(uint32_t); ++i)
136 sprintf(&stringData[2*i],
"%02x", digestData[i]);
137 stringData[2*digest.size()*
sizeof(uint32_t)] = 0;
139 return std::string(stringData);
143 uint32_t a = digest[0];
144 uint32_t b = digest[1];
145 uint32_t c = digest[2];
146 uint32_t
d = digest[3];
148 for (
size_t i = 0; i < 64; ++i) {
152 f = (b & c) | (~b & d);
156 f = (b & d) | (c & ~d);
182 return (value << numBits)|(value >> (
sizeof(uint32_t)*8-numBits));
186 const uint8_t* bytes,
size_t numBytes) {
187 size_t i = numDigestedBits[0]/8 % 64;
188 size_t lengthOfFirstPart = 64-i;
191 if ((numDigestedBits[0] += (numBytes << 3)) < (numBytes << 3))
192 ++numDigestedBits[1];
193 numDigestedBits[1] += (numBytes >> 29);
195 if (numBytes >= lengthOfFirstPart) {
196 std::copy(&bytes[0], &bytes[lengthOfFirstPart],
197 &reinterpret_cast<uint8_t*>(buffer.data())[i]);
200 for (j = lengthOfFirstPart; j+64 <= numBytes; j += 64) {
203 std::copy(&bytes[j], &bytes[j+64], reinterpret_cast<uint8_t*>(
213 std::copy(&bytes[j], &bytes[numBytes],
214 &reinterpret_cast<uint8_t*>(buffer.data())[i]);
218 Size finalNumDigestedBits(numDigestedBits);
219 size_t i = numDigestedBits[0]/8 % 64;
220 size_t paddedLength = (i < 56) ? 56-i : 120-i;
222 update(digest, numDigestedBits, buffer, reinterpret_cast<const uint8_t*>(
223 padding.data()), paddedLength);
224 update(digest, numDigestedBits, buffer, reinterpret_cast<const uint8_t*>(
225 finalNumDigestedBits.data()), 8);
238 md5Sum.
write(stream);
Header file providing the MD5Sum class interface.