45 file.seekg(0, std::ios::end);
47 Int32 length = file.tellg();
49 file.seekg(0, std::ios::beg);
51 char* buffer =
new char [length];
53 file.read(buffer, length);
72 for (
Int32 i = 0; i < 16; ++i)
90 #pragma region Definition
115 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
117 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
122 #define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
123 #define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
124 #define H(x, y, z) ((x) ^ (y) ^ (z))
125 #define I(x, y, z) ((y) ^ ((x) | (~z)))
131 #pragma intrinsic(_rotl)
132 #define ROTATE_LEFT(x, n) _rotl((x), (n))
134 #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
140 #define FF(a, b, c, d, x, s, ac) { \
141 (a) += F ((b), (c), (d)) + (x) + (Int64)(ac); \
142 (a) = ROTATE_LEFT ((a), (s)); \
145 #define GG(a, b, c, d, x, s, ac) { \
146 (a) += G ((b), (c), (d)) + (x) + (Int64)(ac); \
147 (a) = ROTATE_LEFT ((a), (s)); \
150 #define HH(a, b, c, d, x, s, ac) { \
151 (a) += H ((b), (c), (d)) + (x) + (Int64)(ac); \
152 (a) = ROTATE_LEFT ((a), (s)); \
155 #define II(a, b, c, d, x, s, ac) { \
156 (a) += I ((b), (c), (d)) + (x) + (Int64)(ac); \
157 (a) = ROTATE_LEFT ((a), (s)); \
167 context->
state[0] = 0x67452301;
168 context->
state[1] = 0xefcdab89;
169 context->
state[2] = 0x98badcfe;
170 context->
state[3] = 0x10325476;
185 index = (
Int32)((context->
count[0] >> 3) & 0x3F);
188 if ((context->
count[0] += ((
Int64)inputLen << 3))
189 < ((
Int64)inputLen << 3))
193 partLen = 64 - index;
196 if (inputLen >= partLen) {
201 for (i = partLen; i + 63 < inputLen; i += 64)
227 index = (
Int32)((context->
count[0] >> 3) & 0x3f);
228 padLen = (index < 56) ? (56 - index) : (120 - index);
243 const uchar block[64])
254 FF (a, b, c, d, x[ 0],
S11, 0xd76aa478);
255 FF (d, a, b, c, x[ 1],
S12, 0xe8c7b756);
256 FF (c, d, a, b, x[ 2],
S13, 0x242070db);
257 FF (b, c, d, a, x[ 3],
S14, 0xc1bdceee);
258 FF (a, b, c, d, x[ 4],
S11, 0xf57c0faf);
259 FF (d, a, b, c, x[ 5],
S12, 0x4787c62a);
260 FF (c, d, a, b, x[ 6],
S13, 0xa8304613);
261 FF (b, c, d, a, x[ 7],
S14, 0xfd469501);
262 FF (a, b, c, d, x[ 8],
S11, 0x698098d8);
263 FF (d, a, b, c, x[ 9],
S12, 0x8b44f7af);
264 FF (c, d, a, b, x[10],
S13, 0xffff5bb1);
265 FF (b, c, d, a, x[11],
S14, 0x895cd7be);
266 FF (a, b, c, d, x[12],
S11, 0x6b901122);
267 FF (d, a, b, c, x[13],
S12, 0xfd987193);
268 FF (c, d, a, b, x[14],
S13, 0xa679438e);
269 FF (b, c, d, a, x[15],
S14, 0x49b40821);
272 GG (a, b, c, d, x[ 1],
S21, 0xf61e2562);
273 GG (d, a, b, c, x[ 6],
S22, 0xc040b340);
274 GG (c, d, a, b, x[11],
S23, 0x265e5a51);
275 GG (b, c, d, a, x[ 0],
S24, 0xe9b6c7aa);
276 GG (a, b, c, d, x[ 5],
S21, 0xd62f105d);
277 GG (d, a, b, c, x[10],
S22, 0x2441453);
278 GG (c, d, a, b, x[15],
S23, 0xd8a1e681);
279 GG (b, c, d, a, x[ 4],
S24, 0xe7d3fbc8);
280 GG (a, b, c, d, x[ 9],
S21, 0x21e1cde6);
281 GG (d, a, b, c, x[14],
S22, 0xc33707d6);
282 GG (c, d, a, b, x[ 3],
S23, 0xf4d50d87);
283 GG (b, c, d, a, x[ 8],
S24, 0x455a14ed);
284 GG (a, b, c, d, x[13],
S21, 0xa9e3e905);
285 GG (d, a, b, c, x[ 2],
S22, 0xfcefa3f8);
286 GG (c, d, a, b, x[ 7],
S23, 0x676f02d9);
287 GG (b, c, d, a, x[12],
S24, 0x8d2a4c8a);
290 HH (a, b, c, d, x[ 5],
S31, 0xfffa3942);
291 HH (d, a, b, c, x[ 8],
S32, 0x8771f681);
292 HH (c, d, a, b, x[11],
S33, 0x6d9d6122);
293 HH (b, c, d, a, x[14],
S34, 0xfde5380c);
294 HH (a, b, c, d, x[ 1],
S31, 0xa4beea44);
295 HH (d, a, b, c, x[ 4],
S32, 0x4bdecfa9);
296 HH (c, d, a, b, x[ 7],
S33, 0xf6bb4b60);
297 HH (b, c, d, a, x[10],
S34, 0xbebfbc70);
298 HH (a, b, c, d, x[13],
S31, 0x289b7ec6);
299 HH (d, a, b, c, x[ 0],
S32, 0xeaa127fa);
300 HH (c, d, a, b, x[ 3],
S33, 0xd4ef3085);
301 HH (b, c, d, a, x[ 6],
S34, 0x4881d05);
302 HH (a, b, c, d, x[ 9],
S31, 0xd9d4d039);
303 HH (d, a, b, c, x[12],
S32, 0xe6db99e5);
304 HH (c, d, a, b, x[15],
S33, 0x1fa27cf8);
305 HH (b, c, d, a, x[ 2],
S34, 0xc4ac5665);
308 II (a, b, c, d, x[ 0],
S41, 0xf4292244);
309 II (d, a, b, c, x[ 7],
S42, 0x432aff97);
310 II (c, d, a, b, x[14],
S43, 0xab9423a7);
311 II (b, c, d, a, x[ 5],
S44, 0xfc93a039);
312 II (a, b, c, d, x[12],
S41, 0x655b59c3);
313 II (d, a, b, c, x[ 3],
S42, 0x8f0ccc92);
314 II (c, d, a, b, x[10],
S43, 0xffeff47d);
315 II (b, c, d, a, x[ 1],
S44, 0x85845dd1);
316 II (a, b, c, d, x[ 8],
S41, 0x6fa87e4f);
317 II (d, a, b, c, x[15],
S42, 0xfe2ce6e0);
318 II (c, d, a, b, x[ 6],
S43, 0xa3014314);
319 II (b, c, d, a, x[13],
S44, 0x4e0811a1);
320 II (a, b, c, d, x[ 4],
S41, 0xf7537e82);
321 II (d, a, b, c, x[11],
S42, 0xbd3af235);
322 II (c, d, a, b, x[ 2],
S43, 0x2ad7d2bb);
323 II (b, c, d, a, x[ 9],
S44, 0xeb86d391);
342 for (i = 0, j = 0; j < len; i++, j += 4) {
343 output[j] = (
uchar)(input[i] & 0xff);
344 output[j+1] = (
uchar)((input[i] >> 8) & 0xff);
345 output[j+2] = (
uchar)((input[i] >> 16) & 0xff);
346 output[j+3] = (
uchar)((input[i] >> 24) & 0xff);
358 for (i = 0, j = 0; j < len; i++, j += 4)
359 output[i] = ((
Int64)input[j]) | (((
Int64)input[j+1]) << 8) |
360 (((
Int64)input[j+2]) << 16) | (((
Int64)input[j+3]) << 24);
370 for (i = 0; i < len; i++)
371 output[i] = input[i];
381 for (i = 0; i < len; i++)
382 ((
char *)output)[i] = (char)value;