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