js-md5 0.8.3 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,829 @@
1
+ function getDefaultExportFromCjs (x) {
2
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
3
+ }
4
+
5
+ var md5$1 = {exports: {}};
6
+
7
+ /**
8
+ * [js-md5]{@link https://github.com/emn178/js-md5}
9
+ *
10
+ * @namespace md5
11
+ * @version 0.9.2
12
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
13
+ * @copyright Chen, Yi-Cyuan 2014-2026
14
+ * @license MIT
15
+ */
16
+
17
+ (function (module) {
18
+ (function () {
19
+
20
+ var INPUT_ERROR = 'input is invalid type';
21
+ var FINALIZE_ERROR = 'finalize already called';
22
+ var WINDOW = typeof window === 'object';
23
+ var root = WINDOW ? window : {};
24
+ if (root.JS_MD5_NO_WINDOW) {
25
+ WINDOW = false;
26
+ }
27
+ var WEB_WORKER = typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope;
28
+ if (WEB_WORKER) {
29
+ root = self;
30
+ }
31
+ var COMMON_JS = !root.JS_MD5_NO_COMMON_JS && 'object' === 'object' && module.exports;
32
+ var HEX_CHARS = '0123456789abcdef'.split('');
33
+ var EXTRA = [128, 32768, 8388608, -2147483648];
34
+ var OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer'];
35
+ /* istanbul ignore else */
36
+ {
37
+ OUTPUT_TYPES.push('buffer');
38
+ }
39
+ /* istanbul ignore else */
40
+ {
41
+ OUTPUT_TYPES.push('base64');
42
+ }
43
+ /* istanbul ignore next */
44
+ var BASE64_ENCODE_CHAR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('') ;
45
+
46
+ var blocks = [], buffer8;
47
+ {
48
+ var buffer = new ArrayBuffer(68);
49
+ buffer8 = new Uint8Array(buffer);
50
+ blocks = new Uint32Array(buffer);
51
+ }
52
+
53
+ var isArray = Array.isArray;
54
+
55
+ var isView = ArrayBuffer.isView;
56
+
57
+ // [message: string, isString: bool]
58
+ var formatMessage = function (message) {
59
+ var type = typeof message;
60
+ if (type === 'string') {
61
+ return [message, true];
62
+ }
63
+ if (type !== 'object' || message === null) {
64
+ throw new Error(INPUT_ERROR);
65
+ }
66
+ if (message.constructor === ArrayBuffer) {
67
+ return [new Uint8Array(message), false];
68
+ }
69
+ if (!isArray(message) && !isView(message)) {
70
+ throw new Error(INPUT_ERROR);
71
+ }
72
+ return [message, false];
73
+ };
74
+
75
+ /**
76
+ * @method hex
77
+ * @memberof md5
78
+ * @description Output hash as hex string
79
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
80
+ * @returns {String} Hex string
81
+ * @example
82
+ * md5.hex('The quick brown fox jumps over the lazy dog');
83
+ * // equal to
84
+ * md5('The quick brown fox jumps over the lazy dog');
85
+ */
86
+ /**
87
+ * @method digest
88
+ * @memberof md5
89
+ * @description Output hash as bytes array
90
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
91
+ * @returns {Array} Bytes array
92
+ * @example
93
+ * md5.digest('The quick brown fox jumps over the lazy dog');
94
+ */
95
+ /**
96
+ * @method array
97
+ * @memberof md5
98
+ * @description Output hash as bytes array
99
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
100
+ * @returns {Array} Bytes array
101
+ * @example
102
+ * md5.array('The quick brown fox jumps over the lazy dog');
103
+ */
104
+ /**
105
+ * @method arrayBuffer
106
+ * @memberof md5
107
+ * @description Output hash as ArrayBuffer
108
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
109
+ * @returns {ArrayBuffer} ArrayBuffer
110
+ * @example
111
+ * md5.arrayBuffer('The quick brown fox jumps over the lazy dog');
112
+ */
113
+ /**
114
+ * @method buffer
115
+ * @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
116
+ * @memberof md5
117
+ * @description Output hash as ArrayBuffer
118
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
119
+ * @returns {ArrayBuffer} ArrayBuffer
120
+ * @example
121
+ * md5.buffer('The quick brown fox jumps over the lazy dog');
122
+ */
123
+ /**
124
+ * @method base64
125
+ * @memberof md5
126
+ * @description Output hash as base64 string
127
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
128
+ * @returns {String} base64 string
129
+ * @example
130
+ * md5.base64('The quick brown fox jumps over the lazy dog');
131
+ */
132
+ var createOutputMethod = function (outputType) {
133
+ return function (message) {
134
+ return new Md5(true).update(message)[outputType]();
135
+ };
136
+ };
137
+
138
+ /**
139
+ * @method create
140
+ * @memberof md5
141
+ * @description Create Md5 object
142
+ * @returns {Md5} Md5 object.
143
+ * @example
144
+ * var hash = md5.create();
145
+ */
146
+ /**
147
+ * @method update
148
+ * @memberof md5
149
+ * @description Create and update Md5 object
150
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
151
+ * @returns {Md5} Md5 object.
152
+ * @example
153
+ * var hash = md5.update('The quick brown fox jumps over the lazy dog');
154
+ * // equal to
155
+ * var hash = md5.create();
156
+ * hash.update('The quick brown fox jumps over the lazy dog');
157
+ */
158
+ var createMethod = function () {
159
+ var method = createOutputMethod('hex');
160
+ method.create = function () {
161
+ return new Md5();
162
+ };
163
+ method.update = function (message) {
164
+ return method.create().update(message);
165
+ };
166
+ for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
167
+ var type = OUTPUT_TYPES[i];
168
+ method[type] = createOutputMethod(type);
169
+ }
170
+ return method;
171
+ };
172
+
173
+ /**
174
+ * @namespace md5.hmac
175
+ */
176
+ /**
177
+ * @method hex
178
+ * @memberof md5.hmac
179
+ * @description Output hash as hex string
180
+ * @param {String|Array|Uint8Array|ArrayBuffer} key key
181
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
182
+ * @returns {String} Hex string
183
+ * @example
184
+ * md5.hmac.hex('key', 'The quick brown fox jumps over the lazy dog');
185
+ * // equal to
186
+ * md5.hmac('key', 'The quick brown fox jumps over the lazy dog');
187
+ */
188
+
189
+ /**
190
+ * @method digest
191
+ * @memberof md5.hmac
192
+ * @description Output hash as bytes array
193
+ * @param {String|Array|Uint8Array|ArrayBuffer} key key
194
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
195
+ * @returns {Array} Bytes array
196
+ * @example
197
+ * md5.hmac.digest('key', 'The quick brown fox jumps over the lazy dog');
198
+ */
199
+ /**
200
+ * @method array
201
+ * @memberof md5.hmac
202
+ * @description Output hash as bytes array
203
+ * @param {String|Array|Uint8Array|ArrayBuffer} key key
204
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
205
+ * @returns {Array} Bytes array
206
+ * @example
207
+ * md5.hmac.array('key', 'The quick brown fox jumps over the lazy dog');
208
+ */
209
+ /**
210
+ * @method arrayBuffer
211
+ * @memberof md5.hmac
212
+ * @description Output hash as ArrayBuffer
213
+ * @param {String|Array|Uint8Array|ArrayBuffer} key key
214
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
215
+ * @returns {ArrayBuffer} ArrayBuffer
216
+ * @example
217
+ * md5.hmac.arrayBuffer('key', 'The quick brown fox jumps over the lazy dog');
218
+ */
219
+ /**
220
+ * @method buffer
221
+ * @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
222
+ * @memberof md5.hmac
223
+ * @description Output hash as ArrayBuffer
224
+ * @param {String|Array|Uint8Array|ArrayBuffer} key key
225
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
226
+ * @returns {ArrayBuffer} ArrayBuffer
227
+ * @example
228
+ * md5.hmac.buffer('key', 'The quick brown fox jumps over the lazy dog');
229
+ */
230
+ /**
231
+ * @method base64
232
+ * @memberof md5.hmac
233
+ * @description Output hash as base64 string
234
+ * @param {String|Array|Uint8Array|ArrayBuffer} key key
235
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
236
+ * @returns {String} base64 string
237
+ * @example
238
+ * md5.hmac.base64('key', 'The quick brown fox jumps over the lazy dog');
239
+ */
240
+ var createHmacOutputMethod = function (outputType) {
241
+ return function (key, message) {
242
+ return new HmacMd5(key, true).update(message)[outputType]();
243
+ };
244
+ };
245
+
246
+ /**
247
+ * @method create
248
+ * @memberof md5.hmac
249
+ * @description Create HmacMd5 object
250
+ * @param {String|Array|Uint8Array|ArrayBuffer} key key
251
+ * @returns {HmacMd5} HmacMd5 object.
252
+ * @example
253
+ * var hash = md5.hmac.create('key');
254
+ */
255
+ /**
256
+ * @method update
257
+ * @memberof md5.hmac
258
+ * @description Create and update HmacMd5 object
259
+ * @param {String|Array|Uint8Array|ArrayBuffer} key key
260
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
261
+ * @returns {HmacMd5} HmacMd5 object.
262
+ * @example
263
+ * var hash = md5.hmac.update('key', 'The quick brown fox jumps over the lazy dog');
264
+ * // equal to
265
+ * var hash = md5.hmac.create('key');
266
+ * hash.update('The quick brown fox jumps over the lazy dog');
267
+ */
268
+ var createHmacMethod = function () {
269
+ var method = createHmacOutputMethod('hex');
270
+ method.create = function (key) {
271
+ return new HmacMd5(key);
272
+ };
273
+ method.update = function (key, message) {
274
+ return method.create(key).update(message);
275
+ };
276
+ for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
277
+ var type = OUTPUT_TYPES[i];
278
+ method[type] = createHmacOutputMethod(type);
279
+ }
280
+ return method;
281
+ };
282
+
283
+ /**
284
+ * Md5 class
285
+ * @class Md5
286
+ * @description This is internal class.
287
+ * @see {@link md5.create}
288
+ */
289
+ function Md5(sharedMemory) {
290
+ if (sharedMemory) {
291
+ blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] =
292
+ blocks[4] = blocks[5] = blocks[6] = blocks[7] =
293
+ blocks[8] = blocks[9] = blocks[10] = blocks[11] =
294
+ blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
295
+ this.blocks = blocks;
296
+ this.buffer8 = buffer8;
297
+ } else {
298
+ {
299
+ var buffer = new ArrayBuffer(68);
300
+ this.buffer8 = new Uint8Array(buffer);
301
+ this.blocks = new Uint32Array(buffer);
302
+ }
303
+ }
304
+ this.h0 = this.h1 = this.h2 = this.h3 = this.start = this.bytes = this.hBytes = 0;
305
+ this.finalized = this.hashed = false;
306
+ this.first = true;
307
+ }
308
+
309
+ /**
310
+ * @method update
311
+ * @memberof Md5
312
+ * @instance
313
+ * @description Update hash
314
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
315
+ * @returns {Md5} Md5 object.
316
+ * @see {@link md5.update}
317
+ */
318
+ Md5.prototype.update = function (message) {
319
+ if (this.finalized) {
320
+ throw new Error(FINALIZE_ERROR);
321
+ }
322
+
323
+ var result = formatMessage(message);
324
+ message = result[0];
325
+ var isString = result[1];
326
+ var code, index = 0, i, length = message.length, blocks = this.blocks;
327
+ var buffer8 = this.buffer8;
328
+
329
+ while (index < length) {
330
+ if (this.hashed) {
331
+ this.hashed = false;
332
+ blocks[0] = blocks[16];
333
+ blocks[16] = blocks[1] = blocks[2] = blocks[3] =
334
+ blocks[4] = blocks[5] = blocks[6] = blocks[7] =
335
+ blocks[8] = blocks[9] = blocks[10] = blocks[11] =
336
+ blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
337
+ }
338
+
339
+ if (isString) {
340
+ {
341
+ for (i = this.start; index < length && i < 64; ++index) {
342
+ code = message.charCodeAt(index);
343
+ if (code < 0x80) {
344
+ buffer8[i++] = code;
345
+ } else if (code < 0x800) {
346
+ buffer8[i++] = 0xc0 | (code >>> 6);
347
+ buffer8[i++] = 0x80 | (code & 0x3f);
348
+ } else if (code < 0xd800 || code >= 0xe000) {
349
+ buffer8[i++] = 0xe0 | (code >>> 12);
350
+ buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
351
+ buffer8[i++] = 0x80 | (code & 0x3f);
352
+ } else {
353
+ code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
354
+ buffer8[i++] = 0xf0 | (code >>> 18);
355
+ buffer8[i++] = 0x80 | ((code >>> 12) & 0x3f);
356
+ buffer8[i++] = 0x80 | ((code >>> 6) & 0x3f);
357
+ buffer8[i++] = 0x80 | (code & 0x3f);
358
+ }
359
+ }
360
+ }
361
+ } else {
362
+ {
363
+ for (i = this.start; index < length && i < 64; ++index) {
364
+ buffer8[i++] = message[index];
365
+ }
366
+ }
367
+ }
368
+ this.lastByteIndex = i;
369
+ this.bytes += i - this.start;
370
+ if (i >= 64) {
371
+ this.start = i - 64;
372
+ this.hash();
373
+ this.hashed = true;
374
+ } else {
375
+ this.start = i;
376
+ }
377
+ }
378
+ if (this.bytes > 4294967295) {
379
+ this.hBytes += this.bytes / 4294967296 << 0;
380
+ this.bytes = this.bytes % 4294967296;
381
+ }
382
+ return this;
383
+ };
384
+
385
+ Md5.prototype.finalize = function () {
386
+ if (this.finalized) {
387
+ return;
388
+ }
389
+ this.finalized = true;
390
+ var blocks = this.blocks, i = this.lastByteIndex;
391
+ blocks[i >>> 2] |= EXTRA[i & 3];
392
+ if (i >= 56) {
393
+ if (!this.hashed) {
394
+ this.hash();
395
+ }
396
+ blocks[0] = blocks[16];
397
+ blocks[16] = blocks[1] = blocks[2] = blocks[3] =
398
+ blocks[4] = blocks[5] = blocks[6] = blocks[7] =
399
+ blocks[8] = blocks[9] = blocks[10] = blocks[11] =
400
+ blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
401
+ }
402
+ blocks[14] = this.bytes << 3;
403
+ blocks[15] = this.hBytes << 3 | this.bytes >>> 29;
404
+ this.hash();
405
+ };
406
+
407
+ Md5.prototype.hash = function () {
408
+ var a, b, c, d, bc, da, blocks = this.blocks;
409
+
410
+ if (this.first) {
411
+ a = blocks[0] - 680876937;
412
+ a = (a << 7 | a >>> 25) - 271733879 << 0;
413
+ d = (-1732584194 ^ a & 2004318071) + blocks[1] - 117830708;
414
+ d = (d << 12 | d >>> 20) + a << 0;
415
+ c = (-271733879 ^ (d & (a ^ -271733879))) + blocks[2] - 1126478375;
416
+ c = (c << 17 | c >>> 15) + d << 0;
417
+ b = (a ^ (c & (d ^ a))) + blocks[3] - 1316259209;
418
+ b = (b << 22 | b >>> 10) + c << 0;
419
+ } else {
420
+ a = this.h0;
421
+ b = this.h1;
422
+ c = this.h2;
423
+ d = this.h3;
424
+ a += (d ^ (b & (c ^ d))) + blocks[0] - 680876936;
425
+ a = (a << 7 | a >>> 25) + b << 0;
426
+ d += (c ^ (a & (b ^ c))) + blocks[1] - 389564586;
427
+ d = (d << 12 | d >>> 20) + a << 0;
428
+ c += (b ^ (d & (a ^ b))) + blocks[2] + 606105819;
429
+ c = (c << 17 | c >>> 15) + d << 0;
430
+ b += (a ^ (c & (d ^ a))) + blocks[3] - 1044525330;
431
+ b = (b << 22 | b >>> 10) + c << 0;
432
+ }
433
+
434
+ a += (d ^ (b & (c ^ d))) + blocks[4] - 176418897;
435
+ a = (a << 7 | a >>> 25) + b << 0;
436
+ d += (c ^ (a & (b ^ c))) + blocks[5] + 1200080426;
437
+ d = (d << 12 | d >>> 20) + a << 0;
438
+ c += (b ^ (d & (a ^ b))) + blocks[6] - 1473231341;
439
+ c = (c << 17 | c >>> 15) + d << 0;
440
+ b += (a ^ (c & (d ^ a))) + blocks[7] - 45705983;
441
+ b = (b << 22 | b >>> 10) + c << 0;
442
+ a += (d ^ (b & (c ^ d))) + blocks[8] + 1770035416;
443
+ a = (a << 7 | a >>> 25) + b << 0;
444
+ d += (c ^ (a & (b ^ c))) + blocks[9] - 1958414417;
445
+ d = (d << 12 | d >>> 20) + a << 0;
446
+ c += (b ^ (d & (a ^ b))) + blocks[10] - 42063;
447
+ c = (c << 17 | c >>> 15) + d << 0;
448
+ b += (a ^ (c & (d ^ a))) + blocks[11] - 1990404162;
449
+ b = (b << 22 | b >>> 10) + c << 0;
450
+ a += (d ^ (b & (c ^ d))) + blocks[12] + 1804603682;
451
+ a = (a << 7 | a >>> 25) + b << 0;
452
+ d += (c ^ (a & (b ^ c))) + blocks[13] - 40341101;
453
+ d = (d << 12 | d >>> 20) + a << 0;
454
+ c += (b ^ (d & (a ^ b))) + blocks[14] - 1502002290;
455
+ c = (c << 17 | c >>> 15) + d << 0;
456
+ b += (a ^ (c & (d ^ a))) + blocks[15] + 1236535329;
457
+ b = (b << 22 | b >>> 10) + c << 0;
458
+ a += (c ^ (d & (b ^ c))) + blocks[1] - 165796510;
459
+ a = (a << 5 | a >>> 27) + b << 0;
460
+ d += (b ^ (c & (a ^ b))) + blocks[6] - 1069501632;
461
+ d = (d << 9 | d >>> 23) + a << 0;
462
+ c += (a ^ (b & (d ^ a))) + blocks[11] + 643717713;
463
+ c = (c << 14 | c >>> 18) + d << 0;
464
+ b += (d ^ (a & (c ^ d))) + blocks[0] - 373897302;
465
+ b = (b << 20 | b >>> 12) + c << 0;
466
+ a += (c ^ (d & (b ^ c))) + blocks[5] - 701558691;
467
+ a = (a << 5 | a >>> 27) + b << 0;
468
+ d += (b ^ (c & (a ^ b))) + blocks[10] + 38016083;
469
+ d = (d << 9 | d >>> 23) + a << 0;
470
+ c += (a ^ (b & (d ^ a))) + blocks[15] - 660478335;
471
+ c = (c << 14 | c >>> 18) + d << 0;
472
+ b += (d ^ (a & (c ^ d))) + blocks[4] - 405537848;
473
+ b = (b << 20 | b >>> 12) + c << 0;
474
+ a += (c ^ (d & (b ^ c))) + blocks[9] + 568446438;
475
+ a = (a << 5 | a >>> 27) + b << 0;
476
+ d += (b ^ (c & (a ^ b))) + blocks[14] - 1019803690;
477
+ d = (d << 9 | d >>> 23) + a << 0;
478
+ c += (a ^ (b & (d ^ a))) + blocks[3] - 187363961;
479
+ c = (c << 14 | c >>> 18) + d << 0;
480
+ b += (d ^ (a & (c ^ d))) + blocks[8] + 1163531501;
481
+ b = (b << 20 | b >>> 12) + c << 0;
482
+ a += (c ^ (d & (b ^ c))) + blocks[13] - 1444681467;
483
+ a = (a << 5 | a >>> 27) + b << 0;
484
+ d += (b ^ (c & (a ^ b))) + blocks[2] - 51403784;
485
+ d = (d << 9 | d >>> 23) + a << 0;
486
+ c += (a ^ (b & (d ^ a))) + blocks[7] + 1735328473;
487
+ c = (c << 14 | c >>> 18) + d << 0;
488
+ b += (d ^ (a & (c ^ d))) + blocks[12] - 1926607734;
489
+ b = (b << 20 | b >>> 12) + c << 0;
490
+ bc = b ^ c;
491
+ a += (bc ^ d) + blocks[5] - 378558;
492
+ a = (a << 4 | a >>> 28) + b << 0;
493
+ d += (bc ^ a) + blocks[8] - 2022574463;
494
+ d = (d << 11 | d >>> 21) + a << 0;
495
+ da = d ^ a;
496
+ c += (da ^ b) + blocks[11] + 1839030562;
497
+ c = (c << 16 | c >>> 16) + d << 0;
498
+ b += (da ^ c) + blocks[14] - 35309556;
499
+ b = (b << 23 | b >>> 9) + c << 0;
500
+ bc = b ^ c;
501
+ a += (bc ^ d) + blocks[1] - 1530992060;
502
+ a = (a << 4 | a >>> 28) + b << 0;
503
+ d += (bc ^ a) + blocks[4] + 1272893353;
504
+ d = (d << 11 | d >>> 21) + a << 0;
505
+ da = d ^ a;
506
+ c += (da ^ b) + blocks[7] - 155497632;
507
+ c = (c << 16 | c >>> 16) + d << 0;
508
+ b += (da ^ c) + blocks[10] - 1094730640;
509
+ b = (b << 23 | b >>> 9) + c << 0;
510
+ bc = b ^ c;
511
+ a += (bc ^ d) + blocks[13] + 681279174;
512
+ a = (a << 4 | a >>> 28) + b << 0;
513
+ d += (bc ^ a) + blocks[0] - 358537222;
514
+ d = (d << 11 | d >>> 21) + a << 0;
515
+ da = d ^ a;
516
+ c += (da ^ b) + blocks[3] - 722521979;
517
+ c = (c << 16 | c >>> 16) + d << 0;
518
+ b += (da ^ c) + blocks[6] + 76029189;
519
+ b = (b << 23 | b >>> 9) + c << 0;
520
+ bc = b ^ c;
521
+ a += (bc ^ d) + blocks[9] - 640364487;
522
+ a = (a << 4 | a >>> 28) + b << 0;
523
+ d += (bc ^ a) + blocks[12] - 421815835;
524
+ d = (d << 11 | d >>> 21) + a << 0;
525
+ da = d ^ a;
526
+ c += (da ^ b) + blocks[15] + 530742520;
527
+ c = (c << 16 | c >>> 16) + d << 0;
528
+ b += (da ^ c) + blocks[2] - 995338651;
529
+ b = (b << 23 | b >>> 9) + c << 0;
530
+ a += (c ^ (b | ~d)) + blocks[0] - 198630844;
531
+ a = (a << 6 | a >>> 26) + b << 0;
532
+ d += (b ^ (a | ~c)) + blocks[7] + 1126891415;
533
+ d = (d << 10 | d >>> 22) + a << 0;
534
+ c += (a ^ (d | ~b)) + blocks[14] - 1416354905;
535
+ c = (c << 15 | c >>> 17) + d << 0;
536
+ b += (d ^ (c | ~a)) + blocks[5] - 57434055;
537
+ b = (b << 21 | b >>> 11) + c << 0;
538
+ a += (c ^ (b | ~d)) + blocks[12] + 1700485571;
539
+ a = (a << 6 | a >>> 26) + b << 0;
540
+ d += (b ^ (a | ~c)) + blocks[3] - 1894986606;
541
+ d = (d << 10 | d >>> 22) + a << 0;
542
+ c += (a ^ (d | ~b)) + blocks[10] - 1051523;
543
+ c = (c << 15 | c >>> 17) + d << 0;
544
+ b += (d ^ (c | ~a)) + blocks[1] - 2054922799;
545
+ b = (b << 21 | b >>> 11) + c << 0;
546
+ a += (c ^ (b | ~d)) + blocks[8] + 1873313359;
547
+ a = (a << 6 | a >>> 26) + b << 0;
548
+ d += (b ^ (a | ~c)) + blocks[15] - 30611744;
549
+ d = (d << 10 | d >>> 22) + a << 0;
550
+ c += (a ^ (d | ~b)) + blocks[6] - 1560198380;
551
+ c = (c << 15 | c >>> 17) + d << 0;
552
+ b += (d ^ (c | ~a)) + blocks[13] + 1309151649;
553
+ b = (b << 21 | b >>> 11) + c << 0;
554
+ a += (c ^ (b | ~d)) + blocks[4] - 145523070;
555
+ a = (a << 6 | a >>> 26) + b << 0;
556
+ d += (b ^ (a | ~c)) + blocks[11] - 1120210379;
557
+ d = (d << 10 | d >>> 22) + a << 0;
558
+ c += (a ^ (d | ~b)) + blocks[2] + 718787259;
559
+ c = (c << 15 | c >>> 17) + d << 0;
560
+ b += (d ^ (c | ~a)) + blocks[9] - 343485551;
561
+ b = (b << 21 | b >>> 11) + c << 0;
562
+
563
+ if (this.first) {
564
+ this.h0 = a + 1732584193 << 0;
565
+ this.h1 = b - 271733879 << 0;
566
+ this.h2 = c - 1732584194 << 0;
567
+ this.h3 = d + 271733878 << 0;
568
+ this.first = false;
569
+ } else {
570
+ this.h0 = this.h0 + a << 0;
571
+ this.h1 = this.h1 + b << 0;
572
+ this.h2 = this.h2 + c << 0;
573
+ this.h3 = this.h3 + d << 0;
574
+ }
575
+ };
576
+
577
+ /**
578
+ * @method hex
579
+ * @memberof Md5
580
+ * @instance
581
+ * @description Output hash as hex string
582
+ * @returns {String} Hex string
583
+ * @see {@link md5.hex}
584
+ * @example
585
+ * hash.hex();
586
+ */
587
+ Md5.prototype.hex = function () {
588
+ this.finalize();
589
+
590
+ var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3;
591
+
592
+ return HEX_CHARS[(h0 >>> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] +
593
+ HEX_CHARS[(h0 >>> 12) & 0x0F] + HEX_CHARS[(h0 >>> 8) & 0x0F] +
594
+ HEX_CHARS[(h0 >>> 20) & 0x0F] + HEX_CHARS[(h0 >>> 16) & 0x0F] +
595
+ HEX_CHARS[(h0 >>> 28) & 0x0F] + HEX_CHARS[(h0 >>> 24) & 0x0F] +
596
+ HEX_CHARS[(h1 >>> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] +
597
+ HEX_CHARS[(h1 >>> 12) & 0x0F] + HEX_CHARS[(h1 >>> 8) & 0x0F] +
598
+ HEX_CHARS[(h1 >>> 20) & 0x0F] + HEX_CHARS[(h1 >>> 16) & 0x0F] +
599
+ HEX_CHARS[(h1 >>> 28) & 0x0F] + HEX_CHARS[(h1 >>> 24) & 0x0F] +
600
+ HEX_CHARS[(h2 >>> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] +
601
+ HEX_CHARS[(h2 >>> 12) & 0x0F] + HEX_CHARS[(h2 >>> 8) & 0x0F] +
602
+ HEX_CHARS[(h2 >>> 20) & 0x0F] + HEX_CHARS[(h2 >>> 16) & 0x0F] +
603
+ HEX_CHARS[(h2 >>> 28) & 0x0F] + HEX_CHARS[(h2 >>> 24) & 0x0F] +
604
+ HEX_CHARS[(h3 >>> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] +
605
+ HEX_CHARS[(h3 >>> 12) & 0x0F] + HEX_CHARS[(h3 >>> 8) & 0x0F] +
606
+ HEX_CHARS[(h3 >>> 20) & 0x0F] + HEX_CHARS[(h3 >>> 16) & 0x0F] +
607
+ HEX_CHARS[(h3 >>> 28) & 0x0F] + HEX_CHARS[(h3 >>> 24) & 0x0F];
608
+ };
609
+
610
+ /**
611
+ * @method toString
612
+ * @memberof Md5
613
+ * @instance
614
+ * @description Output hash as hex string
615
+ * @returns {String} Hex string
616
+ * @see {@link md5.hex}
617
+ * @example
618
+ * hash.toString();
619
+ */
620
+ Md5.prototype.toString = Md5.prototype.hex;
621
+
622
+ /**
623
+ * @method digest
624
+ * @memberof Md5
625
+ * @instance
626
+ * @description Output hash as bytes array
627
+ * @returns {Array} Bytes array
628
+ * @see {@link md5.digest}
629
+ * @example
630
+ * hash.digest();
631
+ */
632
+ Md5.prototype.digest = function () {
633
+ this.finalize();
634
+
635
+ var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3;
636
+ return [
637
+ h0 & 0xFF, (h0 >>> 8) & 0xFF, (h0 >>> 16) & 0xFF, (h0 >>> 24) & 0xFF,
638
+ h1 & 0xFF, (h1 >>> 8) & 0xFF, (h1 >>> 16) & 0xFF, (h1 >>> 24) & 0xFF,
639
+ h2 & 0xFF, (h2 >>> 8) & 0xFF, (h2 >>> 16) & 0xFF, (h2 >>> 24) & 0xFF,
640
+ h3 & 0xFF, (h3 >>> 8) & 0xFF, (h3 >>> 16) & 0xFF, (h3 >>> 24) & 0xFF
641
+ ];
642
+ };
643
+
644
+ /**
645
+ * @method array
646
+ * @memberof Md5
647
+ * @instance
648
+ * @description Output hash as bytes array
649
+ * @returns {Array} Bytes array
650
+ * @see {@link md5.array}
651
+ * @example
652
+ * hash.array();
653
+ */
654
+ Md5.prototype.array = Md5.prototype.digest;
655
+
656
+ /**
657
+ * @method arrayBuffer
658
+ * @memberof Md5
659
+ * @instance
660
+ * @description Output hash as ArrayBuffer
661
+ * @returns {ArrayBuffer} ArrayBuffer
662
+ * @see {@link md5.arrayBuffer}
663
+ * @example
664
+ * hash.arrayBuffer();
665
+ */
666
+ Md5.prototype.arrayBuffer = function () {
667
+ this.finalize();
668
+
669
+ var buffer = new ArrayBuffer(16);
670
+ var blocks = new Uint32Array(buffer);
671
+ blocks[0] = this.h0;
672
+ blocks[1] = this.h1;
673
+ blocks[2] = this.h2;
674
+ blocks[3] = this.h3;
675
+ return buffer;
676
+ };
677
+
678
+ /**
679
+ * @method buffer
680
+ * @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
681
+ * @memberof Md5
682
+ * @instance
683
+ * @description Output hash as ArrayBuffer
684
+ * @returns {ArrayBuffer} ArrayBuffer
685
+ * @see {@link md5.buffer}
686
+ * @example
687
+ * hash.buffer();
688
+ */
689
+ /* istanbul ignore else */
690
+ {
691
+ Md5.prototype.buffer = Md5.prototype.arrayBuffer;
692
+ }
693
+
694
+ /**
695
+ * @method base64
696
+ * @memberof Md5
697
+ * @instance
698
+ * @description Output hash as base64 string
699
+ * @returns {String} base64 string
700
+ * @see {@link md5.base64}
701
+ * @example
702
+ * hash.base64();
703
+ */
704
+ /* istanbul ignore else */
705
+ {
706
+ Md5.prototype.base64 = function () {
707
+ var v1, v2, v3, base64Str = '', bytes = this.array();
708
+ for (var i = 0; i < 15;) {
709
+ v1 = bytes[i++];
710
+ v2 = bytes[i++];
711
+ v3 = bytes[i++];
712
+ base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] +
713
+ BASE64_ENCODE_CHAR[(v1 << 4 | v2 >>> 4) & 63] +
714
+ BASE64_ENCODE_CHAR[(v2 << 2 | v3 >>> 6) & 63] +
715
+ BASE64_ENCODE_CHAR[v3 & 63];
716
+ }
717
+ v1 = bytes[i];
718
+ base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] +
719
+ BASE64_ENCODE_CHAR[(v1 << 4) & 63] +
720
+ '==';
721
+ return base64Str;
722
+ };
723
+ }
724
+
725
+ /**
726
+ * HmacMd5 class
727
+ * @class HmacMd5
728
+ * @extends Md5
729
+ * @description This is internal class.
730
+ * @see {@link md5.hmac.create}
731
+ */
732
+ function HmacMd5(key, sharedMemory) {
733
+ var i, result = formatMessage(key);
734
+ key = result[0];
735
+ if (result[1]) {
736
+ var bytes = [], length = key.length, index = 0, code;
737
+ for (i = 0; i < length; ++i) {
738
+ code = key.charCodeAt(i);
739
+ if (code < 0x80) {
740
+ bytes[index++] = code;
741
+ } else if (code < 0x800) {
742
+ bytes[index++] = (0xc0 | (code >>> 6));
743
+ bytes[index++] = (0x80 | (code & 0x3f));
744
+ } else if (code < 0xd800 || code >= 0xe000) {
745
+ bytes[index++] = (0xe0 | (code >>> 12));
746
+ bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
747
+ bytes[index++] = (0x80 | (code & 0x3f));
748
+ } else {
749
+ code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff));
750
+ bytes[index++] = (0xf0 | (code >>> 18));
751
+ bytes[index++] = (0x80 | ((code >>> 12) & 0x3f));
752
+ bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
753
+ bytes[index++] = (0x80 | (code & 0x3f));
754
+ }
755
+ }
756
+ key = bytes;
757
+ }
758
+
759
+ if (key.length > 64) {
760
+ key = (new Md5(true)).update(key).array();
761
+ }
762
+
763
+ var oKeyPad = [], iKeyPad = [];
764
+ for (i = 0; i < 64; ++i) {
765
+ var b = key[i] || 0;
766
+ oKeyPad[i] = 0x5c ^ b;
767
+ iKeyPad[i] = 0x36 ^ b;
768
+ }
769
+
770
+ Md5.call(this, sharedMemory);
771
+
772
+ this.update(iKeyPad);
773
+ this.oKeyPad = oKeyPad;
774
+ this.inner = true;
775
+ this.sharedMemory = sharedMemory;
776
+ }
777
+ /* istanbul ignore else */
778
+ {
779
+ HmacMd5.prototype = new Md5();
780
+
781
+ HmacMd5.prototype.finalize = function () {
782
+ Md5.prototype.finalize.call(this);
783
+ if (this.inner) {
784
+ this.inner = false;
785
+ var innerHash = this.array();
786
+ Md5.call(this, this.sharedMemory);
787
+ this.update(this.oKeyPad);
788
+ this.update(innerHash);
789
+ Md5.prototype.finalize.call(this);
790
+ }
791
+ };
792
+ }
793
+
794
+ var exports = createMethod();
795
+ exports.md5 = exports;
796
+ /* istanbul ignore else */
797
+ {
798
+ exports.md5.hmac = createHmacMethod();
799
+ }
800
+
801
+ if (COMMON_JS) {
802
+ module.exports = exports;
803
+ } else {
804
+ /**
805
+ * @method md5
806
+ * @description Md5 hash function, export to global in browsers.
807
+ * @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
808
+ * @returns {String} md5 hashes
809
+ * @example
810
+ * md5(''); // d41d8cd98f00b204e9800998ecf8427e
811
+ * md5('The quick brown fox jumps over the lazy dog'); // 9e107d9d372bb6826bd81d3542a419d6
812
+ * md5('The quick brown fox jumps over the lazy dog.'); // e4d909c290d0fb1ca068ffaddf22cbd0
813
+ *
814
+ * // It also supports UTF-8 encoding
815
+ * md5('中文'); // a7bac2239fcdcb3a067903d8077c4a07
816
+ *
817
+ * // It also supports byte `Array`, `Uint8Array`, `ArrayBuffer`
818
+ * md5([]); // d41d8cd98f00b204e9800998ecf8427e
819
+ * md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e
820
+ */
821
+ root.md5 = exports;
822
+ }
823
+ })();
824
+ } (md5$1));
825
+
826
+ var md5Exports = md5$1.exports;
827
+ var md5 = /*@__PURE__*/getDefaultExportFromCjs(md5Exports);
828
+
829
+ export { md5 as default, md5 };