@kevisual/auth 1.0.5 → 2.0.1

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.
package/dist/salt.mjs DELETED
@@ -1,1130 +0,0 @@
1
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
-
3
- function getDefaultExportFromCjs (x) {
4
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5
- }
6
-
7
- var md5$1 = {exports: {}};
8
-
9
- function commonjsRequire(path) {
10
- throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
11
- }
12
-
13
- var core$1 = {exports: {}};
14
-
15
- var core = core$1.exports;
16
-
17
- var hasRequiredCore;
18
-
19
- function requireCore () {
20
- if (hasRequiredCore) return core$1.exports;
21
- hasRequiredCore = 1;
22
- (function (module, exports) {
23
- (function (root, factory) {
24
- {
25
- // CommonJS
26
- module.exports = factory();
27
- }
28
- }(core, function () {
29
-
30
- /*globals window, global, require*/
31
-
32
- /**
33
- * CryptoJS core components.
34
- */
35
- var CryptoJS = CryptoJS || (function (Math, undefined$1) {
36
-
37
- var crypto;
38
-
39
- // Native crypto from window (Browser)
40
- if (typeof window !== 'undefined' && window.crypto) {
41
- crypto = window.crypto;
42
- }
43
-
44
- // Native crypto in web worker (Browser)
45
- if (typeof self !== 'undefined' && self.crypto) {
46
- crypto = self.crypto;
47
- }
48
-
49
- // Native crypto from worker
50
- if (typeof globalThis !== 'undefined' && globalThis.crypto) {
51
- crypto = globalThis.crypto;
52
- }
53
-
54
- // Native (experimental IE 11) crypto from window (Browser)
55
- if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
56
- crypto = window.msCrypto;
57
- }
58
-
59
- // Native crypto from global (NodeJS)
60
- if (!crypto && typeof commonjsGlobal !== 'undefined' && commonjsGlobal.crypto) {
61
- crypto = commonjsGlobal.crypto;
62
- }
63
-
64
- // Native crypto import via require (NodeJS)
65
- if (!crypto && typeof commonjsRequire === 'function') {
66
- try {
67
- crypto = require('crypto');
68
- } catch (err) {}
69
- }
70
-
71
- /*
72
- * Cryptographically secure pseudorandom number generator
73
- *
74
- * As Math.random() is cryptographically not safe to use
75
- */
76
- var cryptoSecureRandomInt = function () {
77
- if (crypto) {
78
- // Use getRandomValues method (Browser)
79
- if (typeof crypto.getRandomValues === 'function') {
80
- try {
81
- return crypto.getRandomValues(new Uint32Array(1))[0];
82
- } catch (err) {}
83
- }
84
-
85
- // Use randomBytes method (NodeJS)
86
- if (typeof crypto.randomBytes === 'function') {
87
- try {
88
- return crypto.randomBytes(4).readInt32LE();
89
- } catch (err) {}
90
- }
91
- }
92
-
93
- throw new Error('Native crypto module could not be used to get secure random number.');
94
- };
95
-
96
- /*
97
- * Local polyfill of Object.create
98
-
99
- */
100
- var create = Object.create || (function () {
101
- function F() {}
102
-
103
- return function (obj) {
104
- var subtype;
105
-
106
- F.prototype = obj;
107
-
108
- subtype = new F();
109
-
110
- F.prototype = null;
111
-
112
- return subtype;
113
- };
114
- }());
115
-
116
- /**
117
- * CryptoJS namespace.
118
- */
119
- var C = {};
120
-
121
- /**
122
- * Library namespace.
123
- */
124
- var C_lib = C.lib = {};
125
-
126
- /**
127
- * Base object for prototypal inheritance.
128
- */
129
- var Base = C_lib.Base = (function () {
130
-
131
-
132
- return {
133
- /**
134
- * Creates a new object that inherits from this object.
135
- *
136
- * @param {Object} overrides Properties to copy into the new object.
137
- *
138
- * @return {Object} The new object.
139
- *
140
- * @static
141
- *
142
- * @example
143
- *
144
- * var MyType = CryptoJS.lib.Base.extend({
145
- * field: 'value',
146
- *
147
- * method: function () {
148
- * }
149
- * });
150
- */
151
- extend: function (overrides) {
152
- // Spawn
153
- var subtype = create(this);
154
-
155
- // Augment
156
- if (overrides) {
157
- subtype.mixIn(overrides);
158
- }
159
-
160
- // Create default initializer
161
- if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
162
- subtype.init = function () {
163
- subtype.$super.init.apply(this, arguments);
164
- };
165
- }
166
-
167
- // Initializer's prototype is the subtype object
168
- subtype.init.prototype = subtype;
169
-
170
- // Reference supertype
171
- subtype.$super = this;
172
-
173
- return subtype;
174
- },
175
-
176
- /**
177
- * Extends this object and runs the init method.
178
- * Arguments to create() will be passed to init().
179
- *
180
- * @return {Object} The new object.
181
- *
182
- * @static
183
- *
184
- * @example
185
- *
186
- * var instance = MyType.create();
187
- */
188
- create: function () {
189
- var instance = this.extend();
190
- instance.init.apply(instance, arguments);
191
-
192
- return instance;
193
- },
194
-
195
- /**
196
- * Initializes a newly created object.
197
- * Override this method to add some logic when your objects are created.
198
- *
199
- * @example
200
- *
201
- * var MyType = CryptoJS.lib.Base.extend({
202
- * init: function () {
203
- * // ...
204
- * }
205
- * });
206
- */
207
- init: function () {
208
- },
209
-
210
- /**
211
- * Copies properties into this object.
212
- *
213
- * @param {Object} properties The properties to mix in.
214
- *
215
- * @example
216
- *
217
- * MyType.mixIn({
218
- * field: 'value'
219
- * });
220
- */
221
- mixIn: function (properties) {
222
- for (var propertyName in properties) {
223
- if (properties.hasOwnProperty(propertyName)) {
224
- this[propertyName] = properties[propertyName];
225
- }
226
- }
227
-
228
- // IE won't copy toString using the loop above
229
- if (properties.hasOwnProperty('toString')) {
230
- this.toString = properties.toString;
231
- }
232
- },
233
-
234
- /**
235
- * Creates a copy of this object.
236
- *
237
- * @return {Object} The clone.
238
- *
239
- * @example
240
- *
241
- * var clone = instance.clone();
242
- */
243
- clone: function () {
244
- return this.init.prototype.extend(this);
245
- }
246
- };
247
- }());
248
-
249
- /**
250
- * An array of 32-bit words.
251
- *
252
- * @property {Array} words The array of 32-bit words.
253
- * @property {number} sigBytes The number of significant bytes in this word array.
254
- */
255
- var WordArray = C_lib.WordArray = Base.extend({
256
- /**
257
- * Initializes a newly created word array.
258
- *
259
- * @param {Array} words (Optional) An array of 32-bit words.
260
- * @param {number} sigBytes (Optional) The number of significant bytes in the words.
261
- *
262
- * @example
263
- *
264
- * var wordArray = CryptoJS.lib.WordArray.create();
265
- * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
266
- * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
267
- */
268
- init: function (words, sigBytes) {
269
- words = this.words = words || [];
270
-
271
- if (sigBytes != undefined$1) {
272
- this.sigBytes = sigBytes;
273
- } else {
274
- this.sigBytes = words.length * 4;
275
- }
276
- },
277
-
278
- /**
279
- * Converts this word array to a string.
280
- *
281
- * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
282
- *
283
- * @return {string} The stringified word array.
284
- *
285
- * @example
286
- *
287
- * var string = wordArray + '';
288
- * var string = wordArray.toString();
289
- * var string = wordArray.toString(CryptoJS.enc.Utf8);
290
- */
291
- toString: function (encoder) {
292
- return (encoder || Hex).stringify(this);
293
- },
294
-
295
- /**
296
- * Concatenates a word array to this word array.
297
- *
298
- * @param {WordArray} wordArray The word array to append.
299
- *
300
- * @return {WordArray} This word array.
301
- *
302
- * @example
303
- *
304
- * wordArray1.concat(wordArray2);
305
- */
306
- concat: function (wordArray) {
307
- // Shortcuts
308
- var thisWords = this.words;
309
- var thatWords = wordArray.words;
310
- var thisSigBytes = this.sigBytes;
311
- var thatSigBytes = wordArray.sigBytes;
312
-
313
- // Clamp excess bits
314
- this.clamp();
315
-
316
- // Concat
317
- if (thisSigBytes % 4) {
318
- // Copy one byte at a time
319
- for (var i = 0; i < thatSigBytes; i++) {
320
- var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
321
- thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
322
- }
323
- } else {
324
- // Copy one word at a time
325
- for (var j = 0; j < thatSigBytes; j += 4) {
326
- thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];
327
- }
328
- }
329
- this.sigBytes += thatSigBytes;
330
-
331
- // Chainable
332
- return this;
333
- },
334
-
335
- /**
336
- * Removes insignificant bits.
337
- *
338
- * @example
339
- *
340
- * wordArray.clamp();
341
- */
342
- clamp: function () {
343
- // Shortcuts
344
- var words = this.words;
345
- var sigBytes = this.sigBytes;
346
-
347
- // Clamp
348
- words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
349
- words.length = Math.ceil(sigBytes / 4);
350
- },
351
-
352
- /**
353
- * Creates a copy of this word array.
354
- *
355
- * @return {WordArray} The clone.
356
- *
357
- * @example
358
- *
359
- * var clone = wordArray.clone();
360
- */
361
- clone: function () {
362
- var clone = Base.clone.call(this);
363
- clone.words = this.words.slice(0);
364
-
365
- return clone;
366
- },
367
-
368
- /**
369
- * Creates a word array filled with random bytes.
370
- *
371
- * @param {number} nBytes The number of random bytes to generate.
372
- *
373
- * @return {WordArray} The random word array.
374
- *
375
- * @static
376
- *
377
- * @example
378
- *
379
- * var wordArray = CryptoJS.lib.WordArray.random(16);
380
- */
381
- random: function (nBytes) {
382
- var words = [];
383
-
384
- for (var i = 0; i < nBytes; i += 4) {
385
- words.push(cryptoSecureRandomInt());
386
- }
387
-
388
- return new WordArray.init(words, nBytes);
389
- }
390
- });
391
-
392
- /**
393
- * Encoder namespace.
394
- */
395
- var C_enc = C.enc = {};
396
-
397
- /**
398
- * Hex encoding strategy.
399
- */
400
- var Hex = C_enc.Hex = {
401
- /**
402
- * Converts a word array to a hex string.
403
- *
404
- * @param {WordArray} wordArray The word array.
405
- *
406
- * @return {string} The hex string.
407
- *
408
- * @static
409
- *
410
- * @example
411
- *
412
- * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
413
- */
414
- stringify: function (wordArray) {
415
- // Shortcuts
416
- var words = wordArray.words;
417
- var sigBytes = wordArray.sigBytes;
418
-
419
- // Convert
420
- var hexChars = [];
421
- for (var i = 0; i < sigBytes; i++) {
422
- var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
423
- hexChars.push((bite >>> 4).toString(16));
424
- hexChars.push((bite & 0x0f).toString(16));
425
- }
426
-
427
- return hexChars.join('');
428
- },
429
-
430
- /**
431
- * Converts a hex string to a word array.
432
- *
433
- * @param {string} hexStr The hex string.
434
- *
435
- * @return {WordArray} The word array.
436
- *
437
- * @static
438
- *
439
- * @example
440
- *
441
- * var wordArray = CryptoJS.enc.Hex.parse(hexString);
442
- */
443
- parse: function (hexStr) {
444
- // Shortcut
445
- var hexStrLength = hexStr.length;
446
-
447
- // Convert
448
- var words = [];
449
- for (var i = 0; i < hexStrLength; i += 2) {
450
- words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
451
- }
452
-
453
- return new WordArray.init(words, hexStrLength / 2);
454
- }
455
- };
456
-
457
- /**
458
- * Latin1 encoding strategy.
459
- */
460
- var Latin1 = C_enc.Latin1 = {
461
- /**
462
- * Converts a word array to a Latin1 string.
463
- *
464
- * @param {WordArray} wordArray The word array.
465
- *
466
- * @return {string} The Latin1 string.
467
- *
468
- * @static
469
- *
470
- * @example
471
- *
472
- * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
473
- */
474
- stringify: function (wordArray) {
475
- // Shortcuts
476
- var words = wordArray.words;
477
- var sigBytes = wordArray.sigBytes;
478
-
479
- // Convert
480
- var latin1Chars = [];
481
- for (var i = 0; i < sigBytes; i++) {
482
- var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
483
- latin1Chars.push(String.fromCharCode(bite));
484
- }
485
-
486
- return latin1Chars.join('');
487
- },
488
-
489
- /**
490
- * Converts a Latin1 string to a word array.
491
- *
492
- * @param {string} latin1Str The Latin1 string.
493
- *
494
- * @return {WordArray} The word array.
495
- *
496
- * @static
497
- *
498
- * @example
499
- *
500
- * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
501
- */
502
- parse: function (latin1Str) {
503
- // Shortcut
504
- var latin1StrLength = latin1Str.length;
505
-
506
- // Convert
507
- var words = [];
508
- for (var i = 0; i < latin1StrLength; i++) {
509
- words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
510
- }
511
-
512
- return new WordArray.init(words, latin1StrLength);
513
- }
514
- };
515
-
516
- /**
517
- * UTF-8 encoding strategy.
518
- */
519
- var Utf8 = C_enc.Utf8 = {
520
- /**
521
- * Converts a word array to a UTF-8 string.
522
- *
523
- * @param {WordArray} wordArray The word array.
524
- *
525
- * @return {string} The UTF-8 string.
526
- *
527
- * @static
528
- *
529
- * @example
530
- *
531
- * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
532
- */
533
- stringify: function (wordArray) {
534
- try {
535
- return decodeURIComponent(escape(Latin1.stringify(wordArray)));
536
- } catch (e) {
537
- throw new Error('Malformed UTF-8 data');
538
- }
539
- },
540
-
541
- /**
542
- * Converts a UTF-8 string to a word array.
543
- *
544
- * @param {string} utf8Str The UTF-8 string.
545
- *
546
- * @return {WordArray} The word array.
547
- *
548
- * @static
549
- *
550
- * @example
551
- *
552
- * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
553
- */
554
- parse: function (utf8Str) {
555
- return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
556
- }
557
- };
558
-
559
- /**
560
- * Abstract buffered block algorithm template.
561
- *
562
- * The property blockSize must be implemented in a concrete subtype.
563
- *
564
- * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
565
- */
566
- var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
567
- /**
568
- * Resets this block algorithm's data buffer to its initial state.
569
- *
570
- * @example
571
- *
572
- * bufferedBlockAlgorithm.reset();
573
- */
574
- reset: function () {
575
- // Initial values
576
- this._data = new WordArray.init();
577
- this._nDataBytes = 0;
578
- },
579
-
580
- /**
581
- * Adds new data to this block algorithm's buffer.
582
- *
583
- * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
584
- *
585
- * @example
586
- *
587
- * bufferedBlockAlgorithm._append('data');
588
- * bufferedBlockAlgorithm._append(wordArray);
589
- */
590
- _append: function (data) {
591
- // Convert string to WordArray, else assume WordArray already
592
- if (typeof data == 'string') {
593
- data = Utf8.parse(data);
594
- }
595
-
596
- // Append
597
- this._data.concat(data);
598
- this._nDataBytes += data.sigBytes;
599
- },
600
-
601
- /**
602
- * Processes available data blocks.
603
- *
604
- * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
605
- *
606
- * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
607
- *
608
- * @return {WordArray} The processed data.
609
- *
610
- * @example
611
- *
612
- * var processedData = bufferedBlockAlgorithm._process();
613
- * var processedData = bufferedBlockAlgorithm._process(!!'flush');
614
- */
615
- _process: function (doFlush) {
616
- var processedWords;
617
-
618
- // Shortcuts
619
- var data = this._data;
620
- var dataWords = data.words;
621
- var dataSigBytes = data.sigBytes;
622
- var blockSize = this.blockSize;
623
- var blockSizeBytes = blockSize * 4;
624
-
625
- // Count blocks ready
626
- var nBlocksReady = dataSigBytes / blockSizeBytes;
627
- if (doFlush) {
628
- // Round up to include partial blocks
629
- nBlocksReady = Math.ceil(nBlocksReady);
630
- } else {
631
- // Round down to include only full blocks,
632
- // less the number of blocks that must remain in the buffer
633
- nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
634
- }
635
-
636
- // Count words ready
637
- var nWordsReady = nBlocksReady * blockSize;
638
-
639
- // Count bytes ready
640
- var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
641
-
642
- // Process blocks
643
- if (nWordsReady) {
644
- for (var offset = 0; offset < nWordsReady; offset += blockSize) {
645
- // Perform concrete-algorithm logic
646
- this._doProcessBlock(dataWords, offset);
647
- }
648
-
649
- // Remove processed words
650
- processedWords = dataWords.splice(0, nWordsReady);
651
- data.sigBytes -= nBytesReady;
652
- }
653
-
654
- // Return processed words
655
- return new WordArray.init(processedWords, nBytesReady);
656
- },
657
-
658
- /**
659
- * Creates a copy of this object.
660
- *
661
- * @return {Object} The clone.
662
- *
663
- * @example
664
- *
665
- * var clone = bufferedBlockAlgorithm.clone();
666
- */
667
- clone: function () {
668
- var clone = Base.clone.call(this);
669
- clone._data = this._data.clone();
670
-
671
- return clone;
672
- },
673
-
674
- _minBufferSize: 0
675
- });
676
-
677
- /**
678
- * Abstract hasher template.
679
- *
680
- * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
681
- */
682
- C_lib.Hasher = BufferedBlockAlgorithm.extend({
683
- /**
684
- * Configuration options.
685
- */
686
- cfg: Base.extend(),
687
-
688
- /**
689
- * Initializes a newly created hasher.
690
- *
691
- * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
692
- *
693
- * @example
694
- *
695
- * var hasher = CryptoJS.algo.SHA256.create();
696
- */
697
- init: function (cfg) {
698
- // Apply config defaults
699
- this.cfg = this.cfg.extend(cfg);
700
-
701
- // Set initial values
702
- this.reset();
703
- },
704
-
705
- /**
706
- * Resets this hasher to its initial state.
707
- *
708
- * @example
709
- *
710
- * hasher.reset();
711
- */
712
- reset: function () {
713
- // Reset data buffer
714
- BufferedBlockAlgorithm.reset.call(this);
715
-
716
- // Perform concrete-hasher logic
717
- this._doReset();
718
- },
719
-
720
- /**
721
- * Updates this hasher with a message.
722
- *
723
- * @param {WordArray|string} messageUpdate The message to append.
724
- *
725
- * @return {Hasher} This hasher.
726
- *
727
- * @example
728
- *
729
- * hasher.update('message');
730
- * hasher.update(wordArray);
731
- */
732
- update: function (messageUpdate) {
733
- // Append
734
- this._append(messageUpdate);
735
-
736
- // Update the hash
737
- this._process();
738
-
739
- // Chainable
740
- return this;
741
- },
742
-
743
- /**
744
- * Finalizes the hash computation.
745
- * Note that the finalize operation is effectively a destructive, read-once operation.
746
- *
747
- * @param {WordArray|string} messageUpdate (Optional) A final message update.
748
- *
749
- * @return {WordArray} The hash.
750
- *
751
- * @example
752
- *
753
- * var hash = hasher.finalize();
754
- * var hash = hasher.finalize('message');
755
- * var hash = hasher.finalize(wordArray);
756
- */
757
- finalize: function (messageUpdate) {
758
- // Final message update
759
- if (messageUpdate) {
760
- this._append(messageUpdate);
761
- }
762
-
763
- // Perform concrete-hasher logic
764
- var hash = this._doFinalize();
765
-
766
- return hash;
767
- },
768
-
769
- blockSize: 512/32,
770
-
771
- /**
772
- * Creates a shortcut function to a hasher's object interface.
773
- *
774
- * @param {Hasher} hasher The hasher to create a helper for.
775
- *
776
- * @return {Function} The shortcut function.
777
- *
778
- * @static
779
- *
780
- * @example
781
- *
782
- * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
783
- */
784
- _createHelper: function (hasher) {
785
- return function (message, cfg) {
786
- return new hasher.init(cfg).finalize(message);
787
- };
788
- },
789
-
790
- /**
791
- * Creates a shortcut function to the HMAC's object interface.
792
- *
793
- * @param {Hasher} hasher The hasher to use in this HMAC helper.
794
- *
795
- * @return {Function} The shortcut function.
796
- *
797
- * @static
798
- *
799
- * @example
800
- *
801
- * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
802
- */
803
- _createHmacHelper: function (hasher) {
804
- return function (message, key) {
805
- return new C_algo.HMAC.init(hasher, key).finalize(message);
806
- };
807
- }
808
- });
809
-
810
- /**
811
- * Algorithm namespace.
812
- */
813
- var C_algo = C.algo = {};
814
-
815
- return C;
816
- }(Math));
817
-
818
-
819
- return CryptoJS;
820
-
821
- }));
822
- } (core$1));
823
- return core$1.exports;
824
- }
825
-
826
- var md5 = md5$1.exports;
827
-
828
- var hasRequiredMd5;
829
-
830
- function requireMd5 () {
831
- if (hasRequiredMd5) return md5$1.exports;
832
- hasRequiredMd5 = 1;
833
- (function (module, exports) {
834
- (function (root, factory) {
835
- {
836
- // CommonJS
837
- module.exports = factory(requireCore());
838
- }
839
- }(md5, function (CryptoJS) {
840
-
841
- (function (Math) {
842
- // Shortcuts
843
- var C = CryptoJS;
844
- var C_lib = C.lib;
845
- var WordArray = C_lib.WordArray;
846
- var Hasher = C_lib.Hasher;
847
- var C_algo = C.algo;
848
-
849
- // Constants table
850
- var T = [];
851
-
852
- // Compute constants
853
- (function () {
854
- for (var i = 0; i < 64; i++) {
855
- T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
856
- }
857
- }());
858
-
859
- /**
860
- * MD5 hash algorithm.
861
- */
862
- var MD5 = C_algo.MD5 = Hasher.extend({
863
- _doReset: function () {
864
- this._hash = new WordArray.init([
865
- 0x67452301, 0xefcdab89,
866
- 0x98badcfe, 0x10325476
867
- ]);
868
- },
869
-
870
- _doProcessBlock: function (M, offset) {
871
- // Swap endian
872
- for (var i = 0; i < 16; i++) {
873
- // Shortcuts
874
- var offset_i = offset + i;
875
- var M_offset_i = M[offset_i];
876
-
877
- M[offset_i] = (
878
- (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
879
- (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
880
- );
881
- }
882
-
883
- // Shortcuts
884
- var H = this._hash.words;
885
-
886
- var M_offset_0 = M[offset + 0];
887
- var M_offset_1 = M[offset + 1];
888
- var M_offset_2 = M[offset + 2];
889
- var M_offset_3 = M[offset + 3];
890
- var M_offset_4 = M[offset + 4];
891
- var M_offset_5 = M[offset + 5];
892
- var M_offset_6 = M[offset + 6];
893
- var M_offset_7 = M[offset + 7];
894
- var M_offset_8 = M[offset + 8];
895
- var M_offset_9 = M[offset + 9];
896
- var M_offset_10 = M[offset + 10];
897
- var M_offset_11 = M[offset + 11];
898
- var M_offset_12 = M[offset + 12];
899
- var M_offset_13 = M[offset + 13];
900
- var M_offset_14 = M[offset + 14];
901
- var M_offset_15 = M[offset + 15];
902
-
903
- // Working variables
904
- var a = H[0];
905
- var b = H[1];
906
- var c = H[2];
907
- var d = H[3];
908
-
909
- // Computation
910
- a = FF(a, b, c, d, M_offset_0, 7, T[0]);
911
- d = FF(d, a, b, c, M_offset_1, 12, T[1]);
912
- c = FF(c, d, a, b, M_offset_2, 17, T[2]);
913
- b = FF(b, c, d, a, M_offset_3, 22, T[3]);
914
- a = FF(a, b, c, d, M_offset_4, 7, T[4]);
915
- d = FF(d, a, b, c, M_offset_5, 12, T[5]);
916
- c = FF(c, d, a, b, M_offset_6, 17, T[6]);
917
- b = FF(b, c, d, a, M_offset_7, 22, T[7]);
918
- a = FF(a, b, c, d, M_offset_8, 7, T[8]);
919
- d = FF(d, a, b, c, M_offset_9, 12, T[9]);
920
- c = FF(c, d, a, b, M_offset_10, 17, T[10]);
921
- b = FF(b, c, d, a, M_offset_11, 22, T[11]);
922
- a = FF(a, b, c, d, M_offset_12, 7, T[12]);
923
- d = FF(d, a, b, c, M_offset_13, 12, T[13]);
924
- c = FF(c, d, a, b, M_offset_14, 17, T[14]);
925
- b = FF(b, c, d, a, M_offset_15, 22, T[15]);
926
-
927
- a = GG(a, b, c, d, M_offset_1, 5, T[16]);
928
- d = GG(d, a, b, c, M_offset_6, 9, T[17]);
929
- c = GG(c, d, a, b, M_offset_11, 14, T[18]);
930
- b = GG(b, c, d, a, M_offset_0, 20, T[19]);
931
- a = GG(a, b, c, d, M_offset_5, 5, T[20]);
932
- d = GG(d, a, b, c, M_offset_10, 9, T[21]);
933
- c = GG(c, d, a, b, M_offset_15, 14, T[22]);
934
- b = GG(b, c, d, a, M_offset_4, 20, T[23]);
935
- a = GG(a, b, c, d, M_offset_9, 5, T[24]);
936
- d = GG(d, a, b, c, M_offset_14, 9, T[25]);
937
- c = GG(c, d, a, b, M_offset_3, 14, T[26]);
938
- b = GG(b, c, d, a, M_offset_8, 20, T[27]);
939
- a = GG(a, b, c, d, M_offset_13, 5, T[28]);
940
- d = GG(d, a, b, c, M_offset_2, 9, T[29]);
941
- c = GG(c, d, a, b, M_offset_7, 14, T[30]);
942
- b = GG(b, c, d, a, M_offset_12, 20, T[31]);
943
-
944
- a = HH(a, b, c, d, M_offset_5, 4, T[32]);
945
- d = HH(d, a, b, c, M_offset_8, 11, T[33]);
946
- c = HH(c, d, a, b, M_offset_11, 16, T[34]);
947
- b = HH(b, c, d, a, M_offset_14, 23, T[35]);
948
- a = HH(a, b, c, d, M_offset_1, 4, T[36]);
949
- d = HH(d, a, b, c, M_offset_4, 11, T[37]);
950
- c = HH(c, d, a, b, M_offset_7, 16, T[38]);
951
- b = HH(b, c, d, a, M_offset_10, 23, T[39]);
952
- a = HH(a, b, c, d, M_offset_13, 4, T[40]);
953
- d = HH(d, a, b, c, M_offset_0, 11, T[41]);
954
- c = HH(c, d, a, b, M_offset_3, 16, T[42]);
955
- b = HH(b, c, d, a, M_offset_6, 23, T[43]);
956
- a = HH(a, b, c, d, M_offset_9, 4, T[44]);
957
- d = HH(d, a, b, c, M_offset_12, 11, T[45]);
958
- c = HH(c, d, a, b, M_offset_15, 16, T[46]);
959
- b = HH(b, c, d, a, M_offset_2, 23, T[47]);
960
-
961
- a = II(a, b, c, d, M_offset_0, 6, T[48]);
962
- d = II(d, a, b, c, M_offset_7, 10, T[49]);
963
- c = II(c, d, a, b, M_offset_14, 15, T[50]);
964
- b = II(b, c, d, a, M_offset_5, 21, T[51]);
965
- a = II(a, b, c, d, M_offset_12, 6, T[52]);
966
- d = II(d, a, b, c, M_offset_3, 10, T[53]);
967
- c = II(c, d, a, b, M_offset_10, 15, T[54]);
968
- b = II(b, c, d, a, M_offset_1, 21, T[55]);
969
- a = II(a, b, c, d, M_offset_8, 6, T[56]);
970
- d = II(d, a, b, c, M_offset_15, 10, T[57]);
971
- c = II(c, d, a, b, M_offset_6, 15, T[58]);
972
- b = II(b, c, d, a, M_offset_13, 21, T[59]);
973
- a = II(a, b, c, d, M_offset_4, 6, T[60]);
974
- d = II(d, a, b, c, M_offset_11, 10, T[61]);
975
- c = II(c, d, a, b, M_offset_2, 15, T[62]);
976
- b = II(b, c, d, a, M_offset_9, 21, T[63]);
977
-
978
- // Intermediate hash value
979
- H[0] = (H[0] + a) | 0;
980
- H[1] = (H[1] + b) | 0;
981
- H[2] = (H[2] + c) | 0;
982
- H[3] = (H[3] + d) | 0;
983
- },
984
-
985
- _doFinalize: function () {
986
- // Shortcuts
987
- var data = this._data;
988
- var dataWords = data.words;
989
-
990
- var nBitsTotal = this._nDataBytes * 8;
991
- var nBitsLeft = data.sigBytes * 8;
992
-
993
- // Add padding
994
- dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
995
-
996
- var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
997
- var nBitsTotalL = nBitsTotal;
998
- dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
999
- (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
1000
- (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
1001
- );
1002
- dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
1003
- (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
1004
- (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
1005
- );
1006
-
1007
- data.sigBytes = (dataWords.length + 1) * 4;
1008
-
1009
- // Hash final blocks
1010
- this._process();
1011
-
1012
- // Shortcuts
1013
- var hash = this._hash;
1014
- var H = hash.words;
1015
-
1016
- // Swap endian
1017
- for (var i = 0; i < 4; i++) {
1018
- // Shortcut
1019
- var H_i = H[i];
1020
-
1021
- H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
1022
- (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
1023
- }
1024
-
1025
- // Return final computed hash
1026
- return hash;
1027
- },
1028
-
1029
- clone: function () {
1030
- var clone = Hasher.clone.call(this);
1031
- clone._hash = this._hash.clone();
1032
-
1033
- return clone;
1034
- }
1035
- });
1036
-
1037
- function FF(a, b, c, d, x, s, t) {
1038
- var n = a + ((b & c) | (~b & d)) + x + t;
1039
- return ((n << s) | (n >>> (32 - s))) + b;
1040
- }
1041
-
1042
- function GG(a, b, c, d, x, s, t) {
1043
- var n = a + ((b & d) | (c & ~d)) + x + t;
1044
- return ((n << s) | (n >>> (32 - s))) + b;
1045
- }
1046
-
1047
- function HH(a, b, c, d, x, s, t) {
1048
- var n = a + (b ^ c ^ d) + x + t;
1049
- return ((n << s) | (n >>> (32 - s))) + b;
1050
- }
1051
-
1052
- function II(a, b, c, d, x, s, t) {
1053
- var n = a + (c ^ (b | ~d)) + x + t;
1054
- return ((n << s) | (n >>> (32 - s))) + b;
1055
- }
1056
-
1057
- /**
1058
- * Shortcut function to the hasher's object interface.
1059
- *
1060
- * @param {WordArray|string} message The message to hash.
1061
- *
1062
- * @return {WordArray} The hash.
1063
- *
1064
- * @static
1065
- *
1066
- * @example
1067
- *
1068
- * var hash = CryptoJS.MD5('message');
1069
- * var hash = CryptoJS.MD5(wordArray);
1070
- */
1071
- C.MD5 = Hasher._createHelper(MD5);
1072
-
1073
- /**
1074
- * Shortcut function to the HMAC's object interface.
1075
- *
1076
- * @param {WordArray|string} message The message to hash.
1077
- * @param {WordArray|string} key The secret key.
1078
- *
1079
- * @return {WordArray} The HMAC.
1080
- *
1081
- * @static
1082
- *
1083
- * @example
1084
- *
1085
- * var hmac = CryptoJS.HmacMD5(message, key);
1086
- */
1087
- C.HmacMD5 = Hasher._createHmacHelper(MD5);
1088
- }(Math));
1089
-
1090
-
1091
- return CryptoJS.MD5;
1092
-
1093
- }));
1094
- } (md5$1));
1095
- return md5$1.exports;
1096
- }
1097
-
1098
- var md5Exports = requireMd5();
1099
- var MD5 = /*@__PURE__*/getDefaultExportFromCjs(md5Exports);
1100
-
1101
- /**
1102
- * 生成随机盐
1103
- * @returns
1104
- */
1105
- const getRandomSalt = () => {
1106
- return Math.random().toString().slice(2, 7);
1107
- };
1108
- /**
1109
- * 加密密码
1110
- * @param password
1111
- * @param salt
1112
- * @returns
1113
- */
1114
- const cryptPwd = (password, salt = '') => {
1115
- const saltPassword = password + ':' + salt;
1116
- const md5 = MD5(saltPassword);
1117
- return md5.toString();
1118
- };
1119
- /**
1120
- * Check password
1121
- * @param password
1122
- * @param salt
1123
- * @param md5
1124
- * @returns
1125
- */
1126
- const checkPwd = (password, salt, md5) => {
1127
- return cryptPwd(password, salt) === md5;
1128
- };
1129
-
1130
- export { checkPwd, cryptPwd, getRandomSalt };