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