@esri/telemetry-amazon 1.1.3 → 1.1.4
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.
|
@@ -10,1024 +10,554 @@
|
|
|
10
10
|
|
|
11
11
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
12
12
|
|
|
13
|
-
function
|
|
14
|
-
|
|
13
|
+
function getAugmentedNamespace(n) {
|
|
14
|
+
if (n.__esModule) return n;
|
|
15
|
+
var a = Object.defineProperty({}, '__esModule', {value: true});
|
|
16
|
+
Object.keys(n).forEach(function (k) {
|
|
17
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
18
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return n[k];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
return a;
|
|
15
26
|
}
|
|
16
27
|
|
|
17
28
|
var sha256 = {exports: {}};
|
|
18
29
|
|
|
19
|
-
var
|
|
30
|
+
var _nodeResolve_empty = {};
|
|
20
31
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
module.exports = factory();
|
|
26
|
-
}
|
|
27
|
-
}(commonjsGlobal, function () {
|
|
28
|
-
|
|
29
|
-
/*globals window, global, require*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* CryptoJS core components.
|
|
33
|
-
*/
|
|
34
|
-
var CryptoJS = CryptoJS || (function (Math, undefined$1) {
|
|
35
|
-
|
|
36
|
-
var crypto;
|
|
37
|
-
|
|
38
|
-
// Native crypto from window (Browser)
|
|
39
|
-
if (typeof window !== 'undefined' && window.crypto) {
|
|
40
|
-
crypto = window.crypto;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Native crypto in web worker (Browser)
|
|
44
|
-
if (typeof self !== 'undefined' && self.crypto) {
|
|
45
|
-
crypto = self.crypto;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Native crypto from worker
|
|
49
|
-
if (typeof globalThis !== 'undefined' && globalThis.crypto) {
|
|
50
|
-
crypto = globalThis.crypto;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Native (experimental IE 11) crypto from window (Browser)
|
|
54
|
-
if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
|
|
55
|
-
crypto = window.msCrypto;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Native crypto from global (NodeJS)
|
|
59
|
-
if (!crypto && typeof commonjsGlobal !== 'undefined' && commonjsGlobal.crypto) {
|
|
60
|
-
crypto = commonjsGlobal.crypto;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Native crypto import via require (NodeJS)
|
|
64
|
-
if (!crypto && typeof commonjsRequire === 'function') {
|
|
65
|
-
try {
|
|
66
|
-
crypto = require('crypto');
|
|
67
|
-
} catch (err) {}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/*
|
|
71
|
-
* Cryptographically secure pseudorandom number generator
|
|
72
|
-
*
|
|
73
|
-
* As Math.random() is cryptographically not safe to use
|
|
74
|
-
*/
|
|
75
|
-
var cryptoSecureRandomInt = function () {
|
|
76
|
-
if (crypto) {
|
|
77
|
-
// Use getRandomValues method (Browser)
|
|
78
|
-
if (typeof crypto.getRandomValues === 'function') {
|
|
79
|
-
try {
|
|
80
|
-
return crypto.getRandomValues(new Uint32Array(1))[0];
|
|
81
|
-
} catch (err) {}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Use randomBytes method (NodeJS)
|
|
85
|
-
if (typeof crypto.randomBytes === 'function') {
|
|
86
|
-
try {
|
|
87
|
-
return crypto.randomBytes(4).readInt32LE();
|
|
88
|
-
} catch (err) {}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
throw new Error('Native crypto module could not be used to get secure random number.');
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
/*
|
|
96
|
-
* Local polyfill of Object.create
|
|
97
|
-
|
|
98
|
-
*/
|
|
99
|
-
var create = Object.create || (function () {
|
|
100
|
-
function F() {}
|
|
101
|
-
|
|
102
|
-
return function (obj) {
|
|
103
|
-
var subtype;
|
|
104
|
-
|
|
105
|
-
F.prototype = obj;
|
|
106
|
-
|
|
107
|
-
subtype = new F();
|
|
108
|
-
|
|
109
|
-
F.prototype = null;
|
|
110
|
-
|
|
111
|
-
return subtype;
|
|
112
|
-
};
|
|
113
|
-
}());
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* CryptoJS namespace.
|
|
117
|
-
*/
|
|
118
|
-
var C = {};
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Library namespace.
|
|
122
|
-
*/
|
|
123
|
-
var C_lib = C.lib = {};
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Base object for prototypal inheritance.
|
|
127
|
-
*/
|
|
128
|
-
var Base = C_lib.Base = (function () {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return {
|
|
132
|
-
/**
|
|
133
|
-
* Creates a new object that inherits from this object.
|
|
134
|
-
*
|
|
135
|
-
* @param {Object} overrides Properties to copy into the new object.
|
|
136
|
-
*
|
|
137
|
-
* @return {Object} The new object.
|
|
138
|
-
*
|
|
139
|
-
* @static
|
|
140
|
-
*
|
|
141
|
-
* @example
|
|
142
|
-
*
|
|
143
|
-
* var MyType = CryptoJS.lib.Base.extend({
|
|
144
|
-
* field: 'value',
|
|
145
|
-
*
|
|
146
|
-
* method: function () {
|
|
147
|
-
* }
|
|
148
|
-
* });
|
|
149
|
-
*/
|
|
150
|
-
extend: function (overrides) {
|
|
151
|
-
// Spawn
|
|
152
|
-
var subtype = create(this);
|
|
153
|
-
|
|
154
|
-
// Augment
|
|
155
|
-
if (overrides) {
|
|
156
|
-
subtype.mixIn(overrides);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// Create default initializer
|
|
160
|
-
if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
|
|
161
|
-
subtype.init = function () {
|
|
162
|
-
subtype.$super.init.apply(this, arguments);
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// Initializer's prototype is the subtype object
|
|
167
|
-
subtype.init.prototype = subtype;
|
|
168
|
-
|
|
169
|
-
// Reference supertype
|
|
170
|
-
subtype.$super = this;
|
|
171
|
-
|
|
172
|
-
return subtype;
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Extends this object and runs the init method.
|
|
177
|
-
* Arguments to create() will be passed to init().
|
|
178
|
-
*
|
|
179
|
-
* @return {Object} The new object.
|
|
180
|
-
*
|
|
181
|
-
* @static
|
|
182
|
-
*
|
|
183
|
-
* @example
|
|
184
|
-
*
|
|
185
|
-
* var instance = MyType.create();
|
|
186
|
-
*/
|
|
187
|
-
create: function () {
|
|
188
|
-
var instance = this.extend();
|
|
189
|
-
instance.init.apply(instance, arguments);
|
|
190
|
-
|
|
191
|
-
return instance;
|
|
192
|
-
},
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Initializes a newly created object.
|
|
196
|
-
* Override this method to add some logic when your objects are created.
|
|
197
|
-
*
|
|
198
|
-
* @example
|
|
199
|
-
*
|
|
200
|
-
* var MyType = CryptoJS.lib.Base.extend({
|
|
201
|
-
* init: function () {
|
|
202
|
-
* // ...
|
|
203
|
-
* }
|
|
204
|
-
* });
|
|
205
|
-
*/
|
|
206
|
-
init: function () {
|
|
207
|
-
},
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Copies properties into this object.
|
|
211
|
-
*
|
|
212
|
-
* @param {Object} properties The properties to mix in.
|
|
213
|
-
*
|
|
214
|
-
* @example
|
|
215
|
-
*
|
|
216
|
-
* MyType.mixIn({
|
|
217
|
-
* field: 'value'
|
|
218
|
-
* });
|
|
219
|
-
*/
|
|
220
|
-
mixIn: function (properties) {
|
|
221
|
-
for (var propertyName in properties) {
|
|
222
|
-
if (properties.hasOwnProperty(propertyName)) {
|
|
223
|
-
this[propertyName] = properties[propertyName];
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// IE won't copy toString using the loop above
|
|
228
|
-
if (properties.hasOwnProperty('toString')) {
|
|
229
|
-
this.toString = properties.toString;
|
|
230
|
-
}
|
|
231
|
-
},
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Creates a copy of this object.
|
|
235
|
-
*
|
|
236
|
-
* @return {Object} The clone.
|
|
237
|
-
*
|
|
238
|
-
* @example
|
|
239
|
-
*
|
|
240
|
-
* var clone = instance.clone();
|
|
241
|
-
*/
|
|
242
|
-
clone: function () {
|
|
243
|
-
return this.init.prototype.extend(this);
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
}());
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* An array of 32-bit words.
|
|
250
|
-
*
|
|
251
|
-
* @property {Array} words The array of 32-bit words.
|
|
252
|
-
* @property {number} sigBytes The number of significant bytes in this word array.
|
|
253
|
-
*/
|
|
254
|
-
var WordArray = C_lib.WordArray = Base.extend({
|
|
255
|
-
/**
|
|
256
|
-
* Initializes a newly created word array.
|
|
257
|
-
*
|
|
258
|
-
* @param {Array} words (Optional) An array of 32-bit words.
|
|
259
|
-
* @param {number} sigBytes (Optional) The number of significant bytes in the words.
|
|
260
|
-
*
|
|
261
|
-
* @example
|
|
262
|
-
*
|
|
263
|
-
* var wordArray = CryptoJS.lib.WordArray.create();
|
|
264
|
-
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
|
|
265
|
-
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
|
|
266
|
-
*/
|
|
267
|
-
init: function (words, sigBytes) {
|
|
268
|
-
words = this.words = words || [];
|
|
269
|
-
|
|
270
|
-
if (sigBytes != undefined$1) {
|
|
271
|
-
this.sigBytes = sigBytes;
|
|
272
|
-
} else {
|
|
273
|
-
this.sigBytes = words.length * 4;
|
|
274
|
-
}
|
|
275
|
-
},
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Converts this word array to a string.
|
|
279
|
-
*
|
|
280
|
-
* @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
|
|
281
|
-
*
|
|
282
|
-
* @return {string} The stringified word array.
|
|
283
|
-
*
|
|
284
|
-
* @example
|
|
285
|
-
*
|
|
286
|
-
* var string = wordArray + '';
|
|
287
|
-
* var string = wordArray.toString();
|
|
288
|
-
* var string = wordArray.toString(CryptoJS.enc.Utf8);
|
|
289
|
-
*/
|
|
290
|
-
toString: function (encoder) {
|
|
291
|
-
return (encoder || Hex).stringify(this);
|
|
292
|
-
},
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Concatenates a word array to this word array.
|
|
296
|
-
*
|
|
297
|
-
* @param {WordArray} wordArray The word array to append.
|
|
298
|
-
*
|
|
299
|
-
* @return {WordArray} This word array.
|
|
300
|
-
*
|
|
301
|
-
* @example
|
|
302
|
-
*
|
|
303
|
-
* wordArray1.concat(wordArray2);
|
|
304
|
-
*/
|
|
305
|
-
concat: function (wordArray) {
|
|
306
|
-
// Shortcuts
|
|
307
|
-
var thisWords = this.words;
|
|
308
|
-
var thatWords = wordArray.words;
|
|
309
|
-
var thisSigBytes = this.sigBytes;
|
|
310
|
-
var thatSigBytes = wordArray.sigBytes;
|
|
311
|
-
|
|
312
|
-
// Clamp excess bits
|
|
313
|
-
this.clamp();
|
|
314
|
-
|
|
315
|
-
// Concat
|
|
316
|
-
if (thisSigBytes % 4) {
|
|
317
|
-
// Copy one byte at a time
|
|
318
|
-
for (var i = 0; i < thatSigBytes; i++) {
|
|
319
|
-
var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
|
320
|
-
thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
|
|
321
|
-
}
|
|
322
|
-
} else {
|
|
323
|
-
// Copy one word at a time
|
|
324
|
-
for (var j = 0; j < thatSigBytes; j += 4) {
|
|
325
|
-
thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
this.sigBytes += thatSigBytes;
|
|
329
|
-
|
|
330
|
-
// Chainable
|
|
331
|
-
return this;
|
|
332
|
-
},
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* Removes insignificant bits.
|
|
336
|
-
*
|
|
337
|
-
* @example
|
|
338
|
-
*
|
|
339
|
-
* wordArray.clamp();
|
|
340
|
-
*/
|
|
341
|
-
clamp: function () {
|
|
342
|
-
// Shortcuts
|
|
343
|
-
var words = this.words;
|
|
344
|
-
var sigBytes = this.sigBytes;
|
|
345
|
-
|
|
346
|
-
// Clamp
|
|
347
|
-
words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
|
|
348
|
-
words.length = Math.ceil(sigBytes / 4);
|
|
349
|
-
},
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* Creates a copy of this word array.
|
|
353
|
-
*
|
|
354
|
-
* @return {WordArray} The clone.
|
|
355
|
-
*
|
|
356
|
-
* @example
|
|
357
|
-
*
|
|
358
|
-
* var clone = wordArray.clone();
|
|
359
|
-
*/
|
|
360
|
-
clone: function () {
|
|
361
|
-
var clone = Base.clone.call(this);
|
|
362
|
-
clone.words = this.words.slice(0);
|
|
363
|
-
|
|
364
|
-
return clone;
|
|
365
|
-
},
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* Creates a word array filled with random bytes.
|
|
369
|
-
*
|
|
370
|
-
* @param {number} nBytes The number of random bytes to generate.
|
|
371
|
-
*
|
|
372
|
-
* @return {WordArray} The random word array.
|
|
373
|
-
*
|
|
374
|
-
* @static
|
|
375
|
-
*
|
|
376
|
-
* @example
|
|
377
|
-
*
|
|
378
|
-
* var wordArray = CryptoJS.lib.WordArray.random(16);
|
|
379
|
-
*/
|
|
380
|
-
random: function (nBytes) {
|
|
381
|
-
var words = [];
|
|
382
|
-
|
|
383
|
-
for (var i = 0; i < nBytes; i += 4) {
|
|
384
|
-
words.push(cryptoSecureRandomInt());
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
return new WordArray.init(words, nBytes);
|
|
388
|
-
}
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* Encoder namespace.
|
|
393
|
-
*/
|
|
394
|
-
var C_enc = C.enc = {};
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* Hex encoding strategy.
|
|
398
|
-
*/
|
|
399
|
-
var Hex = C_enc.Hex = {
|
|
400
|
-
/**
|
|
401
|
-
* Converts a word array to a hex string.
|
|
402
|
-
*
|
|
403
|
-
* @param {WordArray} wordArray The word array.
|
|
404
|
-
*
|
|
405
|
-
* @return {string} The hex string.
|
|
406
|
-
*
|
|
407
|
-
* @static
|
|
408
|
-
*
|
|
409
|
-
* @example
|
|
410
|
-
*
|
|
411
|
-
* var hexString = CryptoJS.enc.Hex.stringify(wordArray);
|
|
412
|
-
*/
|
|
413
|
-
stringify: function (wordArray) {
|
|
414
|
-
// Shortcuts
|
|
415
|
-
var words = wordArray.words;
|
|
416
|
-
var sigBytes = wordArray.sigBytes;
|
|
417
|
-
|
|
418
|
-
// Convert
|
|
419
|
-
var hexChars = [];
|
|
420
|
-
for (var i = 0; i < sigBytes; i++) {
|
|
421
|
-
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
|
422
|
-
hexChars.push((bite >>> 4).toString(16));
|
|
423
|
-
hexChars.push((bite & 0x0f).toString(16));
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
return hexChars.join('');
|
|
427
|
-
},
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Converts a hex string to a word array.
|
|
431
|
-
*
|
|
432
|
-
* @param {string} hexStr The hex string.
|
|
433
|
-
*
|
|
434
|
-
* @return {WordArray} The word array.
|
|
435
|
-
*
|
|
436
|
-
* @static
|
|
437
|
-
*
|
|
438
|
-
* @example
|
|
439
|
-
*
|
|
440
|
-
* var wordArray = CryptoJS.enc.Hex.parse(hexString);
|
|
441
|
-
*/
|
|
442
|
-
parse: function (hexStr) {
|
|
443
|
-
// Shortcut
|
|
444
|
-
var hexStrLength = hexStr.length;
|
|
445
|
-
|
|
446
|
-
// Convert
|
|
447
|
-
var words = [];
|
|
448
|
-
for (var i = 0; i < hexStrLength; i += 2) {
|
|
449
|
-
words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
return new WordArray.init(words, hexStrLength / 2);
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* Latin1 encoding strategy.
|
|
458
|
-
*/
|
|
459
|
-
var Latin1 = C_enc.Latin1 = {
|
|
460
|
-
/**
|
|
461
|
-
* Converts a word array to a Latin1 string.
|
|
462
|
-
*
|
|
463
|
-
* @param {WordArray} wordArray The word array.
|
|
464
|
-
*
|
|
465
|
-
* @return {string} The Latin1 string.
|
|
466
|
-
*
|
|
467
|
-
* @static
|
|
468
|
-
*
|
|
469
|
-
* @example
|
|
470
|
-
*
|
|
471
|
-
* var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
|
|
472
|
-
*/
|
|
473
|
-
stringify: function (wordArray) {
|
|
474
|
-
// Shortcuts
|
|
475
|
-
var words = wordArray.words;
|
|
476
|
-
var sigBytes = wordArray.sigBytes;
|
|
477
|
-
|
|
478
|
-
// Convert
|
|
479
|
-
var latin1Chars = [];
|
|
480
|
-
for (var i = 0; i < sigBytes; i++) {
|
|
481
|
-
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
|
482
|
-
latin1Chars.push(String.fromCharCode(bite));
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
return latin1Chars.join('');
|
|
486
|
-
},
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* Converts a Latin1 string to a word array.
|
|
490
|
-
*
|
|
491
|
-
* @param {string} latin1Str The Latin1 string.
|
|
492
|
-
*
|
|
493
|
-
* @return {WordArray} The word array.
|
|
494
|
-
*
|
|
495
|
-
* @static
|
|
496
|
-
*
|
|
497
|
-
* @example
|
|
498
|
-
*
|
|
499
|
-
* var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
|
|
500
|
-
*/
|
|
501
|
-
parse: function (latin1Str) {
|
|
502
|
-
// Shortcut
|
|
503
|
-
var latin1StrLength = latin1Str.length;
|
|
504
|
-
|
|
505
|
-
// Convert
|
|
506
|
-
var words = [];
|
|
507
|
-
for (var i = 0; i < latin1StrLength; i++) {
|
|
508
|
-
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
return new WordArray.init(words, latin1StrLength);
|
|
512
|
-
}
|
|
513
|
-
};
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* UTF-8 encoding strategy.
|
|
517
|
-
*/
|
|
518
|
-
var Utf8 = C_enc.Utf8 = {
|
|
519
|
-
/**
|
|
520
|
-
* Converts a word array to a UTF-8 string.
|
|
521
|
-
*
|
|
522
|
-
* @param {WordArray} wordArray The word array.
|
|
523
|
-
*
|
|
524
|
-
* @return {string} The UTF-8 string.
|
|
525
|
-
*
|
|
526
|
-
* @static
|
|
527
|
-
*
|
|
528
|
-
* @example
|
|
529
|
-
*
|
|
530
|
-
* var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
|
|
531
|
-
*/
|
|
532
|
-
stringify: function (wordArray) {
|
|
533
|
-
try {
|
|
534
|
-
return decodeURIComponent(escape(Latin1.stringify(wordArray)));
|
|
535
|
-
} catch (e) {
|
|
536
|
-
throw new Error('Malformed UTF-8 data');
|
|
537
|
-
}
|
|
538
|
-
},
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* Converts a UTF-8 string to a word array.
|
|
542
|
-
*
|
|
543
|
-
* @param {string} utf8Str The UTF-8 string.
|
|
544
|
-
*
|
|
545
|
-
* @return {WordArray} The word array.
|
|
546
|
-
*
|
|
547
|
-
* @static
|
|
548
|
-
*
|
|
549
|
-
* @example
|
|
550
|
-
*
|
|
551
|
-
* var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
|
|
552
|
-
*/
|
|
553
|
-
parse: function (utf8Str) {
|
|
554
|
-
return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
|
|
555
|
-
}
|
|
556
|
-
};
|
|
557
|
-
|
|
558
|
-
/**
|
|
559
|
-
* Abstract buffered block algorithm template.
|
|
560
|
-
*
|
|
561
|
-
* The property blockSize must be implemented in a concrete subtype.
|
|
562
|
-
*
|
|
563
|
-
* @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
|
|
564
|
-
*/
|
|
565
|
-
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
|
|
566
|
-
/**
|
|
567
|
-
* Resets this block algorithm's data buffer to its initial state.
|
|
568
|
-
*
|
|
569
|
-
* @example
|
|
570
|
-
*
|
|
571
|
-
* bufferedBlockAlgorithm.reset();
|
|
572
|
-
*/
|
|
573
|
-
reset: function () {
|
|
574
|
-
// Initial values
|
|
575
|
-
this._data = new WordArray.init();
|
|
576
|
-
this._nDataBytes = 0;
|
|
577
|
-
},
|
|
578
|
-
|
|
579
|
-
/**
|
|
580
|
-
* Adds new data to this block algorithm's buffer.
|
|
581
|
-
*
|
|
582
|
-
* @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
|
|
583
|
-
*
|
|
584
|
-
* @example
|
|
585
|
-
*
|
|
586
|
-
* bufferedBlockAlgorithm._append('data');
|
|
587
|
-
* bufferedBlockAlgorithm._append(wordArray);
|
|
588
|
-
*/
|
|
589
|
-
_append: function (data) {
|
|
590
|
-
// Convert string to WordArray, else assume WordArray already
|
|
591
|
-
if (typeof data == 'string') {
|
|
592
|
-
data = Utf8.parse(data);
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
// Append
|
|
596
|
-
this._data.concat(data);
|
|
597
|
-
this._nDataBytes += data.sigBytes;
|
|
598
|
-
},
|
|
599
|
-
|
|
600
|
-
/**
|
|
601
|
-
* Processes available data blocks.
|
|
602
|
-
*
|
|
603
|
-
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
|
|
604
|
-
*
|
|
605
|
-
* @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
|
|
606
|
-
*
|
|
607
|
-
* @return {WordArray} The processed data.
|
|
608
|
-
*
|
|
609
|
-
* @example
|
|
610
|
-
*
|
|
611
|
-
* var processedData = bufferedBlockAlgorithm._process();
|
|
612
|
-
* var processedData = bufferedBlockAlgorithm._process(!!'flush');
|
|
613
|
-
*/
|
|
614
|
-
_process: function (doFlush) {
|
|
615
|
-
var processedWords;
|
|
616
|
-
|
|
617
|
-
// Shortcuts
|
|
618
|
-
var data = this._data;
|
|
619
|
-
var dataWords = data.words;
|
|
620
|
-
var dataSigBytes = data.sigBytes;
|
|
621
|
-
var blockSize = this.blockSize;
|
|
622
|
-
var blockSizeBytes = blockSize * 4;
|
|
623
|
-
|
|
624
|
-
// Count blocks ready
|
|
625
|
-
var nBlocksReady = dataSigBytes / blockSizeBytes;
|
|
626
|
-
if (doFlush) {
|
|
627
|
-
// Round up to include partial blocks
|
|
628
|
-
nBlocksReady = Math.ceil(nBlocksReady);
|
|
629
|
-
} else {
|
|
630
|
-
// Round down to include only full blocks,
|
|
631
|
-
// less the number of blocks that must remain in the buffer
|
|
632
|
-
nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
// Count words ready
|
|
636
|
-
var nWordsReady = nBlocksReady * blockSize;
|
|
637
|
-
|
|
638
|
-
// Count bytes ready
|
|
639
|
-
var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
|
|
640
|
-
|
|
641
|
-
// Process blocks
|
|
642
|
-
if (nWordsReady) {
|
|
643
|
-
for (var offset = 0; offset < nWordsReady; offset += blockSize) {
|
|
644
|
-
// Perform concrete-algorithm logic
|
|
645
|
-
this._doProcessBlock(dataWords, offset);
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
// Remove processed words
|
|
649
|
-
processedWords = dataWords.splice(0, nWordsReady);
|
|
650
|
-
data.sigBytes -= nBytesReady;
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
// Return processed words
|
|
654
|
-
return new WordArray.init(processedWords, nBytesReady);
|
|
655
|
-
},
|
|
656
|
-
|
|
657
|
-
/**
|
|
658
|
-
* Creates a copy of this object.
|
|
659
|
-
*
|
|
660
|
-
* @return {Object} The clone.
|
|
661
|
-
*
|
|
662
|
-
* @example
|
|
663
|
-
*
|
|
664
|
-
* var clone = bufferedBlockAlgorithm.clone();
|
|
665
|
-
*/
|
|
666
|
-
clone: function () {
|
|
667
|
-
var clone = Base.clone.call(this);
|
|
668
|
-
clone._data = this._data.clone();
|
|
669
|
-
|
|
670
|
-
return clone;
|
|
671
|
-
},
|
|
672
|
-
|
|
673
|
-
_minBufferSize: 0
|
|
674
|
-
});
|
|
675
|
-
|
|
676
|
-
/**
|
|
677
|
-
* Abstract hasher template.
|
|
678
|
-
*
|
|
679
|
-
* @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
|
|
680
|
-
*/
|
|
681
|
-
C_lib.Hasher = BufferedBlockAlgorithm.extend({
|
|
682
|
-
/**
|
|
683
|
-
* Configuration options.
|
|
684
|
-
*/
|
|
685
|
-
cfg: Base.extend(),
|
|
686
|
-
|
|
687
|
-
/**
|
|
688
|
-
* Initializes a newly created hasher.
|
|
689
|
-
*
|
|
690
|
-
* @param {Object} cfg (Optional) The configuration options to use for this hash computation.
|
|
691
|
-
*
|
|
692
|
-
* @example
|
|
693
|
-
*
|
|
694
|
-
* var hasher = CryptoJS.algo.SHA256.create();
|
|
695
|
-
*/
|
|
696
|
-
init: function (cfg) {
|
|
697
|
-
// Apply config defaults
|
|
698
|
-
this.cfg = this.cfg.extend(cfg);
|
|
699
|
-
|
|
700
|
-
// Set initial values
|
|
701
|
-
this.reset();
|
|
702
|
-
},
|
|
703
|
-
|
|
704
|
-
/**
|
|
705
|
-
* Resets this hasher to its initial state.
|
|
706
|
-
*
|
|
707
|
-
* @example
|
|
708
|
-
*
|
|
709
|
-
* hasher.reset();
|
|
710
|
-
*/
|
|
711
|
-
reset: function () {
|
|
712
|
-
// Reset data buffer
|
|
713
|
-
BufferedBlockAlgorithm.reset.call(this);
|
|
714
|
-
|
|
715
|
-
// Perform concrete-hasher logic
|
|
716
|
-
this._doReset();
|
|
717
|
-
},
|
|
718
|
-
|
|
719
|
-
/**
|
|
720
|
-
* Updates this hasher with a message.
|
|
721
|
-
*
|
|
722
|
-
* @param {WordArray|string} messageUpdate The message to append.
|
|
723
|
-
*
|
|
724
|
-
* @return {Hasher} This hasher.
|
|
725
|
-
*
|
|
726
|
-
* @example
|
|
727
|
-
*
|
|
728
|
-
* hasher.update('message');
|
|
729
|
-
* hasher.update(wordArray);
|
|
730
|
-
*/
|
|
731
|
-
update: function (messageUpdate) {
|
|
732
|
-
// Append
|
|
733
|
-
this._append(messageUpdate);
|
|
734
|
-
|
|
735
|
-
// Update the hash
|
|
736
|
-
this._process();
|
|
737
|
-
|
|
738
|
-
// Chainable
|
|
739
|
-
return this;
|
|
740
|
-
},
|
|
741
|
-
|
|
742
|
-
/**
|
|
743
|
-
* Finalizes the hash computation.
|
|
744
|
-
* Note that the finalize operation is effectively a destructive, read-once operation.
|
|
745
|
-
*
|
|
746
|
-
* @param {WordArray|string} messageUpdate (Optional) A final message update.
|
|
747
|
-
*
|
|
748
|
-
* @return {WordArray} The hash.
|
|
749
|
-
*
|
|
750
|
-
* @example
|
|
751
|
-
*
|
|
752
|
-
* var hash = hasher.finalize();
|
|
753
|
-
* var hash = hasher.finalize('message');
|
|
754
|
-
* var hash = hasher.finalize(wordArray);
|
|
755
|
-
*/
|
|
756
|
-
finalize: function (messageUpdate) {
|
|
757
|
-
// Final message update
|
|
758
|
-
if (messageUpdate) {
|
|
759
|
-
this._append(messageUpdate);
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
// Perform concrete-hasher logic
|
|
763
|
-
var hash = this._doFinalize();
|
|
764
|
-
|
|
765
|
-
return hash;
|
|
766
|
-
},
|
|
767
|
-
|
|
768
|
-
blockSize: 512/32,
|
|
769
|
-
|
|
770
|
-
/**
|
|
771
|
-
* Creates a shortcut function to a hasher's object interface.
|
|
772
|
-
*
|
|
773
|
-
* @param {Hasher} hasher The hasher to create a helper for.
|
|
774
|
-
*
|
|
775
|
-
* @return {Function} The shortcut function.
|
|
776
|
-
*
|
|
777
|
-
* @static
|
|
778
|
-
*
|
|
779
|
-
* @example
|
|
780
|
-
*
|
|
781
|
-
* var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
|
|
782
|
-
*/
|
|
783
|
-
_createHelper: function (hasher) {
|
|
784
|
-
return function (message, cfg) {
|
|
785
|
-
return new hasher.init(cfg).finalize(message);
|
|
786
|
-
};
|
|
787
|
-
},
|
|
788
|
-
|
|
789
|
-
/**
|
|
790
|
-
* Creates a shortcut function to the HMAC's object interface.
|
|
791
|
-
*
|
|
792
|
-
* @param {Hasher} hasher The hasher to use in this HMAC helper.
|
|
793
|
-
*
|
|
794
|
-
* @return {Function} The shortcut function.
|
|
795
|
-
*
|
|
796
|
-
* @static
|
|
797
|
-
*
|
|
798
|
-
* @example
|
|
799
|
-
*
|
|
800
|
-
* var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
|
|
801
|
-
*/
|
|
802
|
-
_createHmacHelper: function (hasher) {
|
|
803
|
-
return function (message, key) {
|
|
804
|
-
return new C_algo.HMAC.init(hasher, key).finalize(message);
|
|
805
|
-
};
|
|
806
|
-
}
|
|
807
|
-
});
|
|
808
|
-
|
|
809
|
-
/**
|
|
810
|
-
* Algorithm namespace.
|
|
811
|
-
*/
|
|
812
|
-
var C_algo = C.algo = {};
|
|
813
|
-
|
|
814
|
-
return C;
|
|
815
|
-
}(Math));
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
return CryptoJS;
|
|
819
|
-
|
|
820
|
-
}));
|
|
821
|
-
}(core));
|
|
32
|
+
var _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({
|
|
33
|
+
__proto__: null,
|
|
34
|
+
'default': _nodeResolve_empty
|
|
35
|
+
});
|
|
822
36
|
|
|
823
|
-
|
|
824
|
-
(function (root, factory) {
|
|
825
|
-
{
|
|
826
|
-
// CommonJS
|
|
827
|
-
module.exports = factory(core.exports);
|
|
828
|
-
}
|
|
829
|
-
}(commonjsGlobal, function (CryptoJS) {
|
|
830
|
-
|
|
831
|
-
(function (Math) {
|
|
832
|
-
// Shortcuts
|
|
833
|
-
var C = CryptoJS;
|
|
834
|
-
var C_lib = C.lib;
|
|
835
|
-
var WordArray = C_lib.WordArray;
|
|
836
|
-
var Hasher = C_lib.Hasher;
|
|
837
|
-
var C_algo = C.algo;
|
|
838
|
-
|
|
839
|
-
// Initialization and round constants tables
|
|
840
|
-
var H = [];
|
|
841
|
-
var K = [];
|
|
842
|
-
|
|
843
|
-
// Compute constants
|
|
844
|
-
(function () {
|
|
845
|
-
function isPrime(n) {
|
|
846
|
-
var sqrtN = Math.sqrt(n);
|
|
847
|
-
for (var factor = 2; factor <= sqrtN; factor++) {
|
|
848
|
-
if (!(n % factor)) {
|
|
849
|
-
return false;
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
return true;
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
function getFractionalBits(n) {
|
|
857
|
-
return ((n - (n | 0)) * 0x100000000) | 0;
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
var n = 2;
|
|
861
|
-
var nPrime = 0;
|
|
862
|
-
while (nPrime < 64) {
|
|
863
|
-
if (isPrime(n)) {
|
|
864
|
-
if (nPrime < 8) {
|
|
865
|
-
H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
|
|
866
|
-
}
|
|
867
|
-
K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
|
|
868
|
-
|
|
869
|
-
nPrime++;
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
n++;
|
|
873
|
-
}
|
|
874
|
-
}());
|
|
875
|
-
|
|
876
|
-
// Reusable object
|
|
877
|
-
var W = [];
|
|
878
|
-
|
|
879
|
-
/**
|
|
880
|
-
* SHA-256 hash algorithm.
|
|
881
|
-
*/
|
|
882
|
-
var SHA256 = C_algo.SHA256 = Hasher.extend({
|
|
883
|
-
_doReset: function () {
|
|
884
|
-
this._hash = new WordArray.init(H.slice(0));
|
|
885
|
-
},
|
|
886
|
-
|
|
887
|
-
_doProcessBlock: function (M, offset) {
|
|
888
|
-
// Shortcut
|
|
889
|
-
var H = this._hash.words;
|
|
890
|
-
|
|
891
|
-
// Working variables
|
|
892
|
-
var a = H[0];
|
|
893
|
-
var b = H[1];
|
|
894
|
-
var c = H[2];
|
|
895
|
-
var d = H[3];
|
|
896
|
-
var e = H[4];
|
|
897
|
-
var f = H[5];
|
|
898
|
-
var g = H[6];
|
|
899
|
-
var h = H[7];
|
|
900
|
-
|
|
901
|
-
// Computation
|
|
902
|
-
for (var i = 0; i < 64; i++) {
|
|
903
|
-
if (i < 16) {
|
|
904
|
-
W[i] = M[offset + i] | 0;
|
|
905
|
-
} else {
|
|
906
|
-
var gamma0x = W[i - 15];
|
|
907
|
-
var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
|
|
908
|
-
((gamma0x << 14) | (gamma0x >>> 18)) ^
|
|
909
|
-
(gamma0x >>> 3);
|
|
910
|
-
|
|
911
|
-
var gamma1x = W[i - 2];
|
|
912
|
-
var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
|
|
913
|
-
((gamma1x << 13) | (gamma1x >>> 19)) ^
|
|
914
|
-
(gamma1x >>> 10);
|
|
915
|
-
|
|
916
|
-
W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
var ch = (e & f) ^ (~e & g);
|
|
920
|
-
var maj = (a & b) ^ (a & c) ^ (b & c);
|
|
921
|
-
|
|
922
|
-
var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
|
|
923
|
-
var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
|
|
924
|
-
|
|
925
|
-
var t1 = h + sigma1 + ch + K[i] + W[i];
|
|
926
|
-
var t2 = sigma0 + maj;
|
|
927
|
-
|
|
928
|
-
h = g;
|
|
929
|
-
g = f;
|
|
930
|
-
f = e;
|
|
931
|
-
e = (d + t1) | 0;
|
|
932
|
-
d = c;
|
|
933
|
-
c = b;
|
|
934
|
-
b = a;
|
|
935
|
-
a = (t1 + t2) | 0;
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
// Intermediate hash value
|
|
939
|
-
H[0] = (H[0] + a) | 0;
|
|
940
|
-
H[1] = (H[1] + b) | 0;
|
|
941
|
-
H[2] = (H[2] + c) | 0;
|
|
942
|
-
H[3] = (H[3] + d) | 0;
|
|
943
|
-
H[4] = (H[4] + e) | 0;
|
|
944
|
-
H[5] = (H[5] + f) | 0;
|
|
945
|
-
H[6] = (H[6] + g) | 0;
|
|
946
|
-
H[7] = (H[7] + h) | 0;
|
|
947
|
-
},
|
|
948
|
-
|
|
949
|
-
_doFinalize: function () {
|
|
950
|
-
// Shortcuts
|
|
951
|
-
var data = this._data;
|
|
952
|
-
var dataWords = data.words;
|
|
953
|
-
|
|
954
|
-
var nBitsTotal = this._nDataBytes * 8;
|
|
955
|
-
var nBitsLeft = data.sigBytes * 8;
|
|
956
|
-
|
|
957
|
-
// Add padding
|
|
958
|
-
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
|
959
|
-
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
|
|
960
|
-
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
|
|
961
|
-
data.sigBytes = dataWords.length * 4;
|
|
962
|
-
|
|
963
|
-
// Hash final blocks
|
|
964
|
-
this._process();
|
|
965
|
-
|
|
966
|
-
// Return final computed hash
|
|
967
|
-
return this._hash;
|
|
968
|
-
},
|
|
969
|
-
|
|
970
|
-
clone: function () {
|
|
971
|
-
var clone = Hasher.clone.call(this);
|
|
972
|
-
clone._hash = this._hash.clone();
|
|
973
|
-
|
|
974
|
-
return clone;
|
|
975
|
-
}
|
|
976
|
-
});
|
|
977
|
-
|
|
978
|
-
/**
|
|
979
|
-
* Shortcut function to the hasher's object interface.
|
|
980
|
-
*
|
|
981
|
-
* @param {WordArray|string} message The message to hash.
|
|
982
|
-
*
|
|
983
|
-
* @return {WordArray} The hash.
|
|
984
|
-
*
|
|
985
|
-
* @static
|
|
986
|
-
*
|
|
987
|
-
* @example
|
|
988
|
-
*
|
|
989
|
-
* var hash = CryptoJS.SHA256('message');
|
|
990
|
-
* var hash = CryptoJS.SHA256(wordArray);
|
|
991
|
-
*/
|
|
992
|
-
C.SHA256 = Hasher._createHelper(SHA256);
|
|
993
|
-
|
|
994
|
-
/**
|
|
995
|
-
* Shortcut function to the HMAC's object interface.
|
|
996
|
-
*
|
|
997
|
-
* @param {WordArray|string} message The message to hash.
|
|
998
|
-
* @param {WordArray|string} key The secret key.
|
|
999
|
-
*
|
|
1000
|
-
* @return {WordArray} The HMAC.
|
|
1001
|
-
*
|
|
1002
|
-
* @static
|
|
1003
|
-
*
|
|
1004
|
-
* @example
|
|
1005
|
-
*
|
|
1006
|
-
* var hmac = CryptoJS.HmacSHA256(message, key);
|
|
1007
|
-
*/
|
|
1008
|
-
C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
|
|
1009
|
-
}(Math));
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
return CryptoJS.SHA256;
|
|
1013
|
-
|
|
1014
|
-
}));
|
|
1015
|
-
}(sha256));
|
|
37
|
+
var require$$1 = /*@__PURE__*/getAugmentedNamespace(_nodeResolve_empty$1);
|
|
1016
38
|
|
|
1017
|
-
|
|
39
|
+
/**
|
|
40
|
+
* [js-sha256]{@link https://github.com/emn178/js-sha256}
|
|
41
|
+
*
|
|
42
|
+
* @version 0.11.0
|
|
43
|
+
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
44
|
+
* @copyright Chen, Yi-Cyuan 2014-2024
|
|
45
|
+
* @license MIT
|
|
46
|
+
*/
|
|
1018
47
|
|
|
1019
|
-
(function (module
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
48
|
+
(function (module) {
|
|
49
|
+
/*jslint bitwise: true */
|
|
50
|
+
(function () {
|
|
51
|
+
|
|
52
|
+
var ERROR = 'input is invalid type';
|
|
53
|
+
var WINDOW = typeof window === 'object';
|
|
54
|
+
var root = WINDOW ? window : {};
|
|
55
|
+
if (root.JS_SHA256_NO_WINDOW) {
|
|
56
|
+
WINDOW = false;
|
|
57
|
+
}
|
|
58
|
+
var WEB_WORKER = !WINDOW && typeof self === 'object';
|
|
59
|
+
var NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
|
|
60
|
+
if (NODE_JS) {
|
|
61
|
+
root = commonjsGlobal;
|
|
62
|
+
} else if (WEB_WORKER) {
|
|
63
|
+
root = self;
|
|
64
|
+
}
|
|
65
|
+
var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && 'object' === 'object' && module.exports;
|
|
66
|
+
var ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';
|
|
67
|
+
var HEX_CHARS = '0123456789abcdef'.split('');
|
|
68
|
+
var EXTRA = [-2147483648, 8388608, 32768, 128];
|
|
69
|
+
var SHIFT = [24, 16, 8, 0];
|
|
70
|
+
var K = [
|
|
71
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
72
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
73
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
74
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
75
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
76
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
77
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
78
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
79
|
+
];
|
|
80
|
+
var OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer'];
|
|
81
|
+
|
|
82
|
+
var blocks = [];
|
|
83
|
+
|
|
84
|
+
if (root.JS_SHA256_NO_NODE_JS || !Array.isArray) {
|
|
85
|
+
Array.isArray = function (obj) {
|
|
86
|
+
return Object.prototype.toString.call(obj) === '[object Array]';
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
|
|
91
|
+
ArrayBuffer.isView = function (obj) {
|
|
92
|
+
return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
1026
95
|
|
|
1027
|
-
|
|
96
|
+
var createOutputMethod = function (outputType, is224) {
|
|
97
|
+
return function (message) {
|
|
98
|
+
return new Sha256(is224, true).update(message)[outputType]();
|
|
99
|
+
};
|
|
100
|
+
};
|
|
1028
101
|
|
|
1029
|
-
|
|
1030
|
-
|
|
102
|
+
var createMethod = function (is224) {
|
|
103
|
+
var method = createOutputMethod('hex', is224);
|
|
104
|
+
if (NODE_JS) {
|
|
105
|
+
method = nodeWrap(method, is224);
|
|
106
|
+
}
|
|
107
|
+
method.create = function () {
|
|
108
|
+
return new Sha256(is224);
|
|
109
|
+
};
|
|
110
|
+
method.update = function (message) {
|
|
111
|
+
return method.create().update(message);
|
|
112
|
+
};
|
|
113
|
+
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
|
|
114
|
+
var type = OUTPUT_TYPES[i];
|
|
115
|
+
method[type] = createOutputMethod(type, is224);
|
|
116
|
+
}
|
|
117
|
+
return method;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
var nodeWrap = function (method, is224) {
|
|
121
|
+
var crypto = require$$1;
|
|
122
|
+
var Buffer = require$$1.Buffer;
|
|
123
|
+
var algorithm = is224 ? 'sha224' : 'sha256';
|
|
124
|
+
var bufferFrom;
|
|
125
|
+
if (Buffer.from && !root.JS_SHA256_NO_BUFFER_FROM) {
|
|
126
|
+
bufferFrom = Buffer.from;
|
|
127
|
+
} else {
|
|
128
|
+
bufferFrom = function (message) {
|
|
129
|
+
return new Buffer(message);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
var nodeMethod = function (message) {
|
|
133
|
+
if (typeof message === 'string') {
|
|
134
|
+
return crypto.createHash(algorithm).update(message, 'utf8').digest('hex');
|
|
135
|
+
} else {
|
|
136
|
+
if (message === null || message === undefined) {
|
|
137
|
+
throw new Error(ERROR);
|
|
138
|
+
} else if (message.constructor === ArrayBuffer) {
|
|
139
|
+
message = new Uint8Array(message);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (Array.isArray(message) || ArrayBuffer.isView(message) ||
|
|
143
|
+
message.constructor === Buffer) {
|
|
144
|
+
return crypto.createHash(algorithm).update(bufferFrom(message)).digest('hex');
|
|
145
|
+
} else {
|
|
146
|
+
return method(message);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
return nodeMethod;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
var createHmacOutputMethod = function (outputType, is224) {
|
|
153
|
+
return function (key, message) {
|
|
154
|
+
return new HmacSha256(key, is224, true).update(message)[outputType]();
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
var createHmacMethod = function (is224) {
|
|
159
|
+
var method = createHmacOutputMethod('hex', is224);
|
|
160
|
+
method.create = function (key) {
|
|
161
|
+
return new HmacSha256(key, is224);
|
|
162
|
+
};
|
|
163
|
+
method.update = function (key, message) {
|
|
164
|
+
return method.create(key).update(message);
|
|
165
|
+
};
|
|
166
|
+
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
|
|
167
|
+
var type = OUTPUT_TYPES[i];
|
|
168
|
+
method[type] = createHmacOutputMethod(type, is224);
|
|
169
|
+
}
|
|
170
|
+
return method;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
function Sha256(is224, sharedMemory) {
|
|
174
|
+
if (sharedMemory) {
|
|
175
|
+
blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] =
|
|
176
|
+
blocks[4] = blocks[5] = blocks[6] = blocks[7] =
|
|
177
|
+
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
|
|
178
|
+
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
|
179
|
+
this.blocks = blocks;
|
|
180
|
+
} else {
|
|
181
|
+
this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (is224) {
|
|
185
|
+
this.h0 = 0xc1059ed8;
|
|
186
|
+
this.h1 = 0x367cd507;
|
|
187
|
+
this.h2 = 0x3070dd17;
|
|
188
|
+
this.h3 = 0xf70e5939;
|
|
189
|
+
this.h4 = 0xffc00b31;
|
|
190
|
+
this.h5 = 0x68581511;
|
|
191
|
+
this.h6 = 0x64f98fa7;
|
|
192
|
+
this.h7 = 0xbefa4fa4;
|
|
193
|
+
} else { // 256
|
|
194
|
+
this.h0 = 0x6a09e667;
|
|
195
|
+
this.h1 = 0xbb67ae85;
|
|
196
|
+
this.h2 = 0x3c6ef372;
|
|
197
|
+
this.h3 = 0xa54ff53a;
|
|
198
|
+
this.h4 = 0x510e527f;
|
|
199
|
+
this.h5 = 0x9b05688c;
|
|
200
|
+
this.h6 = 0x1f83d9ab;
|
|
201
|
+
this.h7 = 0x5be0cd19;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
this.block = this.start = this.bytes = this.hBytes = 0;
|
|
205
|
+
this.finalized = this.hashed = false;
|
|
206
|
+
this.first = true;
|
|
207
|
+
this.is224 = is224;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
Sha256.prototype.update = function (message) {
|
|
211
|
+
if (this.finalized) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
var notString, type = typeof message;
|
|
215
|
+
if (type !== 'string') {
|
|
216
|
+
if (type === 'object') {
|
|
217
|
+
if (message === null) {
|
|
218
|
+
throw new Error(ERROR);
|
|
219
|
+
} else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
|
|
220
|
+
message = new Uint8Array(message);
|
|
221
|
+
} else if (!Array.isArray(message)) {
|
|
222
|
+
if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
|
|
223
|
+
throw new Error(ERROR);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
} else {
|
|
227
|
+
throw new Error(ERROR);
|
|
228
|
+
}
|
|
229
|
+
notString = true;
|
|
230
|
+
}
|
|
231
|
+
var code, index = 0, i, length = message.length, blocks = this.blocks;
|
|
232
|
+
while (index < length) {
|
|
233
|
+
if (this.hashed) {
|
|
234
|
+
this.hashed = false;
|
|
235
|
+
blocks[0] = this.block;
|
|
236
|
+
this.block = blocks[16] = blocks[1] = blocks[2] = blocks[3] =
|
|
237
|
+
blocks[4] = blocks[5] = blocks[6] = blocks[7] =
|
|
238
|
+
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
|
|
239
|
+
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (notString) {
|
|
243
|
+
for (i = this.start; index < length && i < 64; ++index) {
|
|
244
|
+
blocks[i >>> 2] |= message[index] << SHIFT[i++ & 3];
|
|
245
|
+
}
|
|
246
|
+
} else {
|
|
247
|
+
for (i = this.start; index < length && i < 64; ++index) {
|
|
248
|
+
code = message.charCodeAt(index);
|
|
249
|
+
if (code < 0x80) {
|
|
250
|
+
blocks[i >>> 2] |= code << SHIFT[i++ & 3];
|
|
251
|
+
} else if (code < 0x800) {
|
|
252
|
+
blocks[i >>> 2] |= (0xc0 | (code >>> 6)) << SHIFT[i++ & 3];
|
|
253
|
+
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
|
254
|
+
} else if (code < 0xd800 || code >= 0xe000) {
|
|
255
|
+
blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3];
|
|
256
|
+
blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
|
|
257
|
+
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
|
258
|
+
} else {
|
|
259
|
+
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
|
|
260
|
+
blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3];
|
|
261
|
+
blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3];
|
|
262
|
+
blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
|
|
263
|
+
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
this.lastByteIndex = i;
|
|
269
|
+
this.bytes += i - this.start;
|
|
270
|
+
if (i >= 64) {
|
|
271
|
+
this.block = blocks[16];
|
|
272
|
+
this.start = i - 64;
|
|
273
|
+
this.hash();
|
|
274
|
+
this.hashed = true;
|
|
275
|
+
} else {
|
|
276
|
+
this.start = i;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (this.bytes > 4294967295) {
|
|
280
|
+
this.hBytes += this.bytes / 4294967296 << 0;
|
|
281
|
+
this.bytes = this.bytes % 4294967296;
|
|
282
|
+
}
|
|
283
|
+
return this;
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
Sha256.prototype.finalize = function () {
|
|
287
|
+
if (this.finalized) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
this.finalized = true;
|
|
291
|
+
var blocks = this.blocks, i = this.lastByteIndex;
|
|
292
|
+
blocks[16] = this.block;
|
|
293
|
+
blocks[i >>> 2] |= EXTRA[i & 3];
|
|
294
|
+
this.block = blocks[16];
|
|
295
|
+
if (i >= 56) {
|
|
296
|
+
if (!this.hashed) {
|
|
297
|
+
this.hash();
|
|
298
|
+
}
|
|
299
|
+
blocks[0] = this.block;
|
|
300
|
+
blocks[16] = blocks[1] = blocks[2] = blocks[3] =
|
|
301
|
+
blocks[4] = blocks[5] = blocks[6] = blocks[7] =
|
|
302
|
+
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
|
|
303
|
+
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
|
304
|
+
}
|
|
305
|
+
blocks[14] = this.hBytes << 3 | this.bytes >>> 29;
|
|
306
|
+
blocks[15] = this.bytes << 3;
|
|
307
|
+
this.hash();
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
Sha256.prototype.hash = function () {
|
|
311
|
+
var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4, f = this.h5, g = this.h6,
|
|
312
|
+
h = this.h7, blocks = this.blocks, j, s0, s1, maj, t1, t2, ch, ab, da, cd, bc;
|
|
313
|
+
|
|
314
|
+
for (j = 16; j < 64; ++j) {
|
|
315
|
+
// rightrotate
|
|
316
|
+
t1 = blocks[j - 15];
|
|
317
|
+
s0 = ((t1 >>> 7) | (t1 << 25)) ^ ((t1 >>> 18) | (t1 << 14)) ^ (t1 >>> 3);
|
|
318
|
+
t1 = blocks[j - 2];
|
|
319
|
+
s1 = ((t1 >>> 17) | (t1 << 15)) ^ ((t1 >>> 19) | (t1 << 13)) ^ (t1 >>> 10);
|
|
320
|
+
blocks[j] = blocks[j - 16] + s0 + blocks[j - 7] + s1 << 0;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
bc = b & c;
|
|
324
|
+
for (j = 0; j < 64; j += 4) {
|
|
325
|
+
if (this.first) {
|
|
326
|
+
if (this.is224) {
|
|
327
|
+
ab = 300032;
|
|
328
|
+
t1 = blocks[0] - 1413257819;
|
|
329
|
+
h = t1 - 150054599 << 0;
|
|
330
|
+
d = t1 + 24177077 << 0;
|
|
331
|
+
} else {
|
|
332
|
+
ab = 704751109;
|
|
333
|
+
t1 = blocks[0] - 210244248;
|
|
334
|
+
h = t1 - 1521486534 << 0;
|
|
335
|
+
d = t1 + 143694565 << 0;
|
|
336
|
+
}
|
|
337
|
+
this.first = false;
|
|
338
|
+
} else {
|
|
339
|
+
s0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10));
|
|
340
|
+
s1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7));
|
|
341
|
+
ab = a & b;
|
|
342
|
+
maj = ab ^ (a & c) ^ bc;
|
|
343
|
+
ch = (e & f) ^ (~e & g);
|
|
344
|
+
t1 = h + s1 + ch + K[j] + blocks[j];
|
|
345
|
+
t2 = s0 + maj;
|
|
346
|
+
h = d + t1 << 0;
|
|
347
|
+
d = t1 + t2 << 0;
|
|
348
|
+
}
|
|
349
|
+
s0 = ((d >>> 2) | (d << 30)) ^ ((d >>> 13) | (d << 19)) ^ ((d >>> 22) | (d << 10));
|
|
350
|
+
s1 = ((h >>> 6) | (h << 26)) ^ ((h >>> 11) | (h << 21)) ^ ((h >>> 25) | (h << 7));
|
|
351
|
+
da = d & a;
|
|
352
|
+
maj = da ^ (d & b) ^ ab;
|
|
353
|
+
ch = (h & e) ^ (~h & f);
|
|
354
|
+
t1 = g + s1 + ch + K[j + 1] + blocks[j + 1];
|
|
355
|
+
t2 = s0 + maj;
|
|
356
|
+
g = c + t1 << 0;
|
|
357
|
+
c = t1 + t2 << 0;
|
|
358
|
+
s0 = ((c >>> 2) | (c << 30)) ^ ((c >>> 13) | (c << 19)) ^ ((c >>> 22) | (c << 10));
|
|
359
|
+
s1 = ((g >>> 6) | (g << 26)) ^ ((g >>> 11) | (g << 21)) ^ ((g >>> 25) | (g << 7));
|
|
360
|
+
cd = c & d;
|
|
361
|
+
maj = cd ^ (c & a) ^ da;
|
|
362
|
+
ch = (g & h) ^ (~g & e);
|
|
363
|
+
t1 = f + s1 + ch + K[j + 2] + blocks[j + 2];
|
|
364
|
+
t2 = s0 + maj;
|
|
365
|
+
f = b + t1 << 0;
|
|
366
|
+
b = t1 + t2 << 0;
|
|
367
|
+
s0 = ((b >>> 2) | (b << 30)) ^ ((b >>> 13) | (b << 19)) ^ ((b >>> 22) | (b << 10));
|
|
368
|
+
s1 = ((f >>> 6) | (f << 26)) ^ ((f >>> 11) | (f << 21)) ^ ((f >>> 25) | (f << 7));
|
|
369
|
+
bc = b & c;
|
|
370
|
+
maj = bc ^ (b & d) ^ cd;
|
|
371
|
+
ch = (f & g) ^ (~f & h);
|
|
372
|
+
t1 = e + s1 + ch + K[j + 3] + blocks[j + 3];
|
|
373
|
+
t2 = s0 + maj;
|
|
374
|
+
e = a + t1 << 0;
|
|
375
|
+
a = t1 + t2 << 0;
|
|
376
|
+
this.chromeBugWorkAround = true;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
this.h0 = this.h0 + a << 0;
|
|
380
|
+
this.h1 = this.h1 + b << 0;
|
|
381
|
+
this.h2 = this.h2 + c << 0;
|
|
382
|
+
this.h3 = this.h3 + d << 0;
|
|
383
|
+
this.h4 = this.h4 + e << 0;
|
|
384
|
+
this.h5 = this.h5 + f << 0;
|
|
385
|
+
this.h6 = this.h6 + g << 0;
|
|
386
|
+
this.h7 = this.h7 + h << 0;
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
Sha256.prototype.hex = function () {
|
|
390
|
+
this.finalize();
|
|
391
|
+
|
|
392
|
+
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5,
|
|
393
|
+
h6 = this.h6, h7 = this.h7;
|
|
394
|
+
|
|
395
|
+
var hex = HEX_CHARS[(h0 >>> 28) & 0x0F] + HEX_CHARS[(h0 >>> 24) & 0x0F] +
|
|
396
|
+
HEX_CHARS[(h0 >>> 20) & 0x0F] + HEX_CHARS[(h0 >>> 16) & 0x0F] +
|
|
397
|
+
HEX_CHARS[(h0 >>> 12) & 0x0F] + HEX_CHARS[(h0 >>> 8) & 0x0F] +
|
|
398
|
+
HEX_CHARS[(h0 >>> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] +
|
|
399
|
+
HEX_CHARS[(h1 >>> 28) & 0x0F] + HEX_CHARS[(h1 >>> 24) & 0x0F] +
|
|
400
|
+
HEX_CHARS[(h1 >>> 20) & 0x0F] + HEX_CHARS[(h1 >>> 16) & 0x0F] +
|
|
401
|
+
HEX_CHARS[(h1 >>> 12) & 0x0F] + HEX_CHARS[(h1 >>> 8) & 0x0F] +
|
|
402
|
+
HEX_CHARS[(h1 >>> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] +
|
|
403
|
+
HEX_CHARS[(h2 >>> 28) & 0x0F] + HEX_CHARS[(h2 >>> 24) & 0x0F] +
|
|
404
|
+
HEX_CHARS[(h2 >>> 20) & 0x0F] + HEX_CHARS[(h2 >>> 16) & 0x0F] +
|
|
405
|
+
HEX_CHARS[(h2 >>> 12) & 0x0F] + HEX_CHARS[(h2 >>> 8) & 0x0F] +
|
|
406
|
+
HEX_CHARS[(h2 >>> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] +
|
|
407
|
+
HEX_CHARS[(h3 >>> 28) & 0x0F] + HEX_CHARS[(h3 >>> 24) & 0x0F] +
|
|
408
|
+
HEX_CHARS[(h3 >>> 20) & 0x0F] + HEX_CHARS[(h3 >>> 16) & 0x0F] +
|
|
409
|
+
HEX_CHARS[(h3 >>> 12) & 0x0F] + HEX_CHARS[(h3 >>> 8) & 0x0F] +
|
|
410
|
+
HEX_CHARS[(h3 >>> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] +
|
|
411
|
+
HEX_CHARS[(h4 >>> 28) & 0x0F] + HEX_CHARS[(h4 >>> 24) & 0x0F] +
|
|
412
|
+
HEX_CHARS[(h4 >>> 20) & 0x0F] + HEX_CHARS[(h4 >>> 16) & 0x0F] +
|
|
413
|
+
HEX_CHARS[(h4 >>> 12) & 0x0F] + HEX_CHARS[(h4 >>> 8) & 0x0F] +
|
|
414
|
+
HEX_CHARS[(h4 >>> 4) & 0x0F] + HEX_CHARS[h4 & 0x0F] +
|
|
415
|
+
HEX_CHARS[(h5 >>> 28) & 0x0F] + HEX_CHARS[(h5 >>> 24) & 0x0F] +
|
|
416
|
+
HEX_CHARS[(h5 >>> 20) & 0x0F] + HEX_CHARS[(h5 >>> 16) & 0x0F] +
|
|
417
|
+
HEX_CHARS[(h5 >>> 12) & 0x0F] + HEX_CHARS[(h5 >>> 8) & 0x0F] +
|
|
418
|
+
HEX_CHARS[(h5 >>> 4) & 0x0F] + HEX_CHARS[h5 & 0x0F] +
|
|
419
|
+
HEX_CHARS[(h6 >>> 28) & 0x0F] + HEX_CHARS[(h6 >>> 24) & 0x0F] +
|
|
420
|
+
HEX_CHARS[(h6 >>> 20) & 0x0F] + HEX_CHARS[(h6 >>> 16) & 0x0F] +
|
|
421
|
+
HEX_CHARS[(h6 >>> 12) & 0x0F] + HEX_CHARS[(h6 >>> 8) & 0x0F] +
|
|
422
|
+
HEX_CHARS[(h6 >>> 4) & 0x0F] + HEX_CHARS[h6 & 0x0F];
|
|
423
|
+
if (!this.is224) {
|
|
424
|
+
hex += HEX_CHARS[(h7 >>> 28) & 0x0F] + HEX_CHARS[(h7 >>> 24) & 0x0F] +
|
|
425
|
+
HEX_CHARS[(h7 >>> 20) & 0x0F] + HEX_CHARS[(h7 >>> 16) & 0x0F] +
|
|
426
|
+
HEX_CHARS[(h7 >>> 12) & 0x0F] + HEX_CHARS[(h7 >>> 8) & 0x0F] +
|
|
427
|
+
HEX_CHARS[(h7 >>> 4) & 0x0F] + HEX_CHARS[h7 & 0x0F];
|
|
428
|
+
}
|
|
429
|
+
return hex;
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
Sha256.prototype.toString = Sha256.prototype.hex;
|
|
433
|
+
|
|
434
|
+
Sha256.prototype.digest = function () {
|
|
435
|
+
this.finalize();
|
|
436
|
+
|
|
437
|
+
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5,
|
|
438
|
+
h6 = this.h6, h7 = this.h7;
|
|
439
|
+
|
|
440
|
+
var arr = [
|
|
441
|
+
(h0 >>> 24) & 0xFF, (h0 >>> 16) & 0xFF, (h0 >>> 8) & 0xFF, h0 & 0xFF,
|
|
442
|
+
(h1 >>> 24) & 0xFF, (h1 >>> 16) & 0xFF, (h1 >>> 8) & 0xFF, h1 & 0xFF,
|
|
443
|
+
(h2 >>> 24) & 0xFF, (h2 >>> 16) & 0xFF, (h2 >>> 8) & 0xFF, h2 & 0xFF,
|
|
444
|
+
(h3 >>> 24) & 0xFF, (h3 >>> 16) & 0xFF, (h3 >>> 8) & 0xFF, h3 & 0xFF,
|
|
445
|
+
(h4 >>> 24) & 0xFF, (h4 >>> 16) & 0xFF, (h4 >>> 8) & 0xFF, h4 & 0xFF,
|
|
446
|
+
(h5 >>> 24) & 0xFF, (h5 >>> 16) & 0xFF, (h5 >>> 8) & 0xFF, h5 & 0xFF,
|
|
447
|
+
(h6 >>> 24) & 0xFF, (h6 >>> 16) & 0xFF, (h6 >>> 8) & 0xFF, h6 & 0xFF
|
|
448
|
+
];
|
|
449
|
+
if (!this.is224) {
|
|
450
|
+
arr.push((h7 >>> 24) & 0xFF, (h7 >>> 16) & 0xFF, (h7 >>> 8) & 0xFF, h7 & 0xFF);
|
|
451
|
+
}
|
|
452
|
+
return arr;
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
Sha256.prototype.array = Sha256.prototype.digest;
|
|
456
|
+
|
|
457
|
+
Sha256.prototype.arrayBuffer = function () {
|
|
458
|
+
this.finalize();
|
|
459
|
+
|
|
460
|
+
var buffer = new ArrayBuffer(this.is224 ? 28 : 32);
|
|
461
|
+
var dataView = new DataView(buffer);
|
|
462
|
+
dataView.setUint32(0, this.h0);
|
|
463
|
+
dataView.setUint32(4, this.h1);
|
|
464
|
+
dataView.setUint32(8, this.h2);
|
|
465
|
+
dataView.setUint32(12, this.h3);
|
|
466
|
+
dataView.setUint32(16, this.h4);
|
|
467
|
+
dataView.setUint32(20, this.h5);
|
|
468
|
+
dataView.setUint32(24, this.h6);
|
|
469
|
+
if (!this.is224) {
|
|
470
|
+
dataView.setUint32(28, this.h7);
|
|
471
|
+
}
|
|
472
|
+
return buffer;
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
function HmacSha256(key, is224, sharedMemory) {
|
|
476
|
+
var i, type = typeof key;
|
|
477
|
+
if (type === 'string') {
|
|
478
|
+
var bytes = [], length = key.length, index = 0, code;
|
|
479
|
+
for (i = 0; i < length; ++i) {
|
|
480
|
+
code = key.charCodeAt(i);
|
|
481
|
+
if (code < 0x80) {
|
|
482
|
+
bytes[index++] = code;
|
|
483
|
+
} else if (code < 0x800) {
|
|
484
|
+
bytes[index++] = (0xc0 | (code >>> 6));
|
|
485
|
+
bytes[index++] = (0x80 | (code & 0x3f));
|
|
486
|
+
} else if (code < 0xd800 || code >= 0xe000) {
|
|
487
|
+
bytes[index++] = (0xe0 | (code >>> 12));
|
|
488
|
+
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
|
|
489
|
+
bytes[index++] = (0x80 | (code & 0x3f));
|
|
490
|
+
} else {
|
|
491
|
+
code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff));
|
|
492
|
+
bytes[index++] = (0xf0 | (code >>> 18));
|
|
493
|
+
bytes[index++] = (0x80 | ((code >>> 12) & 0x3f));
|
|
494
|
+
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
|
|
495
|
+
bytes[index++] = (0x80 | (code & 0x3f));
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
key = bytes;
|
|
499
|
+
} else {
|
|
500
|
+
if (type === 'object') {
|
|
501
|
+
if (key === null) {
|
|
502
|
+
throw new Error(ERROR);
|
|
503
|
+
} else if (ARRAY_BUFFER && key.constructor === ArrayBuffer) {
|
|
504
|
+
key = new Uint8Array(key);
|
|
505
|
+
} else if (!Array.isArray(key)) {
|
|
506
|
+
if (!ARRAY_BUFFER || !ArrayBuffer.isView(key)) {
|
|
507
|
+
throw new Error(ERROR);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
} else {
|
|
511
|
+
throw new Error(ERROR);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
if (key.length > 64) {
|
|
516
|
+
key = (new Sha256(is224, true)).update(key).array();
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
var oKeyPad = [], iKeyPad = [];
|
|
520
|
+
for (i = 0; i < 64; ++i) {
|
|
521
|
+
var b = key[i] || 0;
|
|
522
|
+
oKeyPad[i] = 0x5c ^ b;
|
|
523
|
+
iKeyPad[i] = 0x36 ^ b;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
Sha256.call(this, is224, sharedMemory);
|
|
527
|
+
|
|
528
|
+
this.update(iKeyPad);
|
|
529
|
+
this.oKeyPad = oKeyPad;
|
|
530
|
+
this.inner = true;
|
|
531
|
+
this.sharedMemory = sharedMemory;
|
|
532
|
+
}
|
|
533
|
+
HmacSha256.prototype = new Sha256();
|
|
534
|
+
|
|
535
|
+
HmacSha256.prototype.finalize = function () {
|
|
536
|
+
Sha256.prototype.finalize.call(this);
|
|
537
|
+
if (this.inner) {
|
|
538
|
+
this.inner = false;
|
|
539
|
+
var innerHash = this.array();
|
|
540
|
+
Sha256.call(this, this.is224, this.sharedMemory);
|
|
541
|
+
this.update(this.oKeyPad);
|
|
542
|
+
this.update(innerHash);
|
|
543
|
+
Sha256.prototype.finalize.call(this);
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
var exports = createMethod();
|
|
548
|
+
exports.sha256 = exports;
|
|
549
|
+
exports.sha224 = createMethod(true);
|
|
550
|
+
exports.sha256.hmac = createHmacMethod();
|
|
551
|
+
exports.sha224.hmac = createHmacMethod(true);
|
|
552
|
+
|
|
553
|
+
if (COMMON_JS) {
|
|
554
|
+
module.exports = exports;
|
|
555
|
+
} else {
|
|
556
|
+
root.sha256 = exports.sha256;
|
|
557
|
+
root.sha224 = exports.sha224;
|
|
558
|
+
}
|
|
559
|
+
})();
|
|
560
|
+
}(sha256));
|
|
1031
561
|
|
|
1032
562
|
const storage$1 = {
|
|
1033
563
|
storage: {},
|