@stacksjs/security 0.57.3 → 0.58.19
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/README.md +5 -5
- package/dist/index.js +3288 -0
- package/package.json +31 -22
- package/LICENSE.md +0 -21
- package/dist/crypt.d.ts +0 -3
- package/dist/crypt.mjs +0 -16
- package/dist/hash.d.ts +0 -8
- package/dist/hash.mjs +0 -38
- package/dist/index.d.ts +0 -3
- package/dist/index.mjs +0 -3
- package/dist/key.d.ts +0 -1
- package/dist/key.mjs +0 -9
package/dist/index.js
ADDED
|
@@ -0,0 +1,3288 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
|
+
var __require = (id) => {
|
|
20
|
+
return import.meta.require(id);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// /Users/chrisbreuer/Code/stacks/node_modules/crypto-js/core.js
|
|
24
|
+
var require_core = __commonJS((exports, module) => {
|
|
25
|
+
(function(root, factory) {
|
|
26
|
+
if (typeof exports === "object") {
|
|
27
|
+
module.exports = exports = factory();
|
|
28
|
+
} else if (typeof define === "function" && define.amd) {
|
|
29
|
+
define([], factory);
|
|
30
|
+
} else {
|
|
31
|
+
root.CryptoJS = factory();
|
|
32
|
+
}
|
|
33
|
+
})(exports, function() {
|
|
34
|
+
var CryptoJS = CryptoJS || function(Math2, undefined2) {
|
|
35
|
+
var crypto;
|
|
36
|
+
if (typeof window !== "undefined" && window.crypto) {
|
|
37
|
+
crypto = window.crypto;
|
|
38
|
+
}
|
|
39
|
+
if (typeof self !== "undefined" && self.crypto) {
|
|
40
|
+
crypto = self.crypto;
|
|
41
|
+
}
|
|
42
|
+
if (typeof globalThis !== "undefined" && globalThis.crypto) {
|
|
43
|
+
crypto = globalThis.crypto;
|
|
44
|
+
}
|
|
45
|
+
if (!crypto && typeof window !== "undefined" && window.msCrypto) {
|
|
46
|
+
crypto = window.msCrypto;
|
|
47
|
+
}
|
|
48
|
+
if (!crypto && typeof global !== "undefined" && global.crypto) {
|
|
49
|
+
crypto = global.crypto;
|
|
50
|
+
}
|
|
51
|
+
if (!crypto && typeof require === "function") {
|
|
52
|
+
try {
|
|
53
|
+
crypto = import.meta.require("crypto");
|
|
54
|
+
} catch (err) {
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
var cryptoSecureRandomInt = function() {
|
|
58
|
+
if (crypto) {
|
|
59
|
+
if (typeof crypto.getRandomValues === "function") {
|
|
60
|
+
try {
|
|
61
|
+
return crypto.getRandomValues(new Uint32Array(1))[0];
|
|
62
|
+
} catch (err) {
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (typeof crypto.randomBytes === "function") {
|
|
66
|
+
try {
|
|
67
|
+
return crypto.randomBytes(4).readInt32LE();
|
|
68
|
+
} catch (err) {
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
throw new Error("Native crypto module could not be used to get secure random number.");
|
|
73
|
+
};
|
|
74
|
+
var create = Object.create || function() {
|
|
75
|
+
function F() {
|
|
76
|
+
}
|
|
77
|
+
return function(obj) {
|
|
78
|
+
var subtype;
|
|
79
|
+
F.prototype = obj;
|
|
80
|
+
subtype = new F;
|
|
81
|
+
F.prototype = null;
|
|
82
|
+
return subtype;
|
|
83
|
+
};
|
|
84
|
+
}();
|
|
85
|
+
var C = {};
|
|
86
|
+
var C_lib = C.lib = {};
|
|
87
|
+
var Base = C_lib.Base = function() {
|
|
88
|
+
return {
|
|
89
|
+
extend: function(overrides) {
|
|
90
|
+
var subtype = create(this);
|
|
91
|
+
if (overrides) {
|
|
92
|
+
subtype.mixIn(overrides);
|
|
93
|
+
}
|
|
94
|
+
if (!subtype.hasOwnProperty("init") || this.init === subtype.init) {
|
|
95
|
+
subtype.init = function() {
|
|
96
|
+
subtype.$super.init.apply(this, arguments);
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
subtype.init.prototype = subtype;
|
|
100
|
+
subtype.$super = this;
|
|
101
|
+
return subtype;
|
|
102
|
+
},
|
|
103
|
+
create: function() {
|
|
104
|
+
var instance = this.extend();
|
|
105
|
+
instance.init.apply(instance, arguments);
|
|
106
|
+
return instance;
|
|
107
|
+
},
|
|
108
|
+
init: function() {
|
|
109
|
+
},
|
|
110
|
+
mixIn: function(properties) {
|
|
111
|
+
for (var propertyName in properties) {
|
|
112
|
+
if (properties.hasOwnProperty(propertyName)) {
|
|
113
|
+
this[propertyName] = properties[propertyName];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (properties.hasOwnProperty("toString")) {
|
|
117
|
+
this.toString = properties.toString;
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
clone: function() {
|
|
121
|
+
return this.init.prototype.extend(this);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}();
|
|
125
|
+
var WordArray = C_lib.WordArray = Base.extend({
|
|
126
|
+
init: function(words, sigBytes) {
|
|
127
|
+
words = this.words = words || [];
|
|
128
|
+
if (sigBytes != undefined2) {
|
|
129
|
+
this.sigBytes = sigBytes;
|
|
130
|
+
} else {
|
|
131
|
+
this.sigBytes = words.length * 4;
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
toString: function(encoder) {
|
|
135
|
+
return (encoder || Hex).stringify(this);
|
|
136
|
+
},
|
|
137
|
+
concat: function(wordArray) {
|
|
138
|
+
var thisWords = this.words;
|
|
139
|
+
var thatWords = wordArray.words;
|
|
140
|
+
var thisSigBytes = this.sigBytes;
|
|
141
|
+
var thatSigBytes = wordArray.sigBytes;
|
|
142
|
+
this.clamp();
|
|
143
|
+
if (thisSigBytes % 4) {
|
|
144
|
+
for (var i = 0;i < thatSigBytes; i++) {
|
|
145
|
+
var thatByte = thatWords[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
146
|
+
thisWords[thisSigBytes + i >>> 2] |= thatByte << 24 - (thisSigBytes + i) % 4 * 8;
|
|
147
|
+
}
|
|
148
|
+
} else {
|
|
149
|
+
for (var j = 0;j < thatSigBytes; j += 4) {
|
|
150
|
+
thisWords[thisSigBytes + j >>> 2] = thatWords[j >>> 2];
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
this.sigBytes += thatSigBytes;
|
|
154
|
+
return this;
|
|
155
|
+
},
|
|
156
|
+
clamp: function() {
|
|
157
|
+
var words = this.words;
|
|
158
|
+
var sigBytes = this.sigBytes;
|
|
159
|
+
words[sigBytes >>> 2] &= 4294967295 << 32 - sigBytes % 4 * 8;
|
|
160
|
+
words.length = Math2.ceil(sigBytes / 4);
|
|
161
|
+
},
|
|
162
|
+
clone: function() {
|
|
163
|
+
var clone = Base.clone.call(this);
|
|
164
|
+
clone.words = this.words.slice(0);
|
|
165
|
+
return clone;
|
|
166
|
+
},
|
|
167
|
+
random: function(nBytes) {
|
|
168
|
+
var words = [];
|
|
169
|
+
for (var i = 0;i < nBytes; i += 4) {
|
|
170
|
+
words.push(cryptoSecureRandomInt());
|
|
171
|
+
}
|
|
172
|
+
return new WordArray.init(words, nBytes);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
var C_enc = C.enc = {};
|
|
176
|
+
var Hex = C_enc.Hex = {
|
|
177
|
+
stringify: function(wordArray) {
|
|
178
|
+
var words = wordArray.words;
|
|
179
|
+
var sigBytes = wordArray.sigBytes;
|
|
180
|
+
var hexChars = [];
|
|
181
|
+
for (var i = 0;i < sigBytes; i++) {
|
|
182
|
+
var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
183
|
+
hexChars.push((bite >>> 4).toString(16));
|
|
184
|
+
hexChars.push((bite & 15).toString(16));
|
|
185
|
+
}
|
|
186
|
+
return hexChars.join("");
|
|
187
|
+
},
|
|
188
|
+
parse: function(hexStr) {
|
|
189
|
+
var hexStrLength = hexStr.length;
|
|
190
|
+
var words = [];
|
|
191
|
+
for (var i = 0;i < hexStrLength; i += 2) {
|
|
192
|
+
words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << 24 - i % 8 * 4;
|
|
193
|
+
}
|
|
194
|
+
return new WordArray.init(words, hexStrLength / 2);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
var Latin1 = C_enc.Latin1 = {
|
|
198
|
+
stringify: function(wordArray) {
|
|
199
|
+
var words = wordArray.words;
|
|
200
|
+
var sigBytes = wordArray.sigBytes;
|
|
201
|
+
var latin1Chars = [];
|
|
202
|
+
for (var i = 0;i < sigBytes; i++) {
|
|
203
|
+
var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
204
|
+
latin1Chars.push(String.fromCharCode(bite));
|
|
205
|
+
}
|
|
206
|
+
return latin1Chars.join("");
|
|
207
|
+
},
|
|
208
|
+
parse: function(latin1Str) {
|
|
209
|
+
var latin1StrLength = latin1Str.length;
|
|
210
|
+
var words = [];
|
|
211
|
+
for (var i = 0;i < latin1StrLength; i++) {
|
|
212
|
+
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 255) << 24 - i % 4 * 8;
|
|
213
|
+
}
|
|
214
|
+
return new WordArray.init(words, latin1StrLength);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
var Utf8 = C_enc.Utf8 = {
|
|
218
|
+
stringify: function(wordArray) {
|
|
219
|
+
try {
|
|
220
|
+
return decodeURIComponent(escape(Latin1.stringify(wordArray)));
|
|
221
|
+
} catch (e) {
|
|
222
|
+
throw new Error("Malformed UTF-8 data");
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
parse: function(utf8Str) {
|
|
226
|
+
return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
|
|
230
|
+
reset: function() {
|
|
231
|
+
this._data = new WordArray.init;
|
|
232
|
+
this._nDataBytes = 0;
|
|
233
|
+
},
|
|
234
|
+
_append: function(data) {
|
|
235
|
+
if (typeof data == "string") {
|
|
236
|
+
data = Utf8.parse(data);
|
|
237
|
+
}
|
|
238
|
+
this._data.concat(data);
|
|
239
|
+
this._nDataBytes += data.sigBytes;
|
|
240
|
+
},
|
|
241
|
+
_process: function(doFlush) {
|
|
242
|
+
var processedWords;
|
|
243
|
+
var data = this._data;
|
|
244
|
+
var dataWords = data.words;
|
|
245
|
+
var dataSigBytes = data.sigBytes;
|
|
246
|
+
var blockSize = this.blockSize;
|
|
247
|
+
var blockSizeBytes = blockSize * 4;
|
|
248
|
+
var nBlocksReady = dataSigBytes / blockSizeBytes;
|
|
249
|
+
if (doFlush) {
|
|
250
|
+
nBlocksReady = Math2.ceil(nBlocksReady);
|
|
251
|
+
} else {
|
|
252
|
+
nBlocksReady = Math2.max((nBlocksReady | 0) - this._minBufferSize, 0);
|
|
253
|
+
}
|
|
254
|
+
var nWordsReady = nBlocksReady * blockSize;
|
|
255
|
+
var nBytesReady = Math2.min(nWordsReady * 4, dataSigBytes);
|
|
256
|
+
if (nWordsReady) {
|
|
257
|
+
for (var offset = 0;offset < nWordsReady; offset += blockSize) {
|
|
258
|
+
this._doProcessBlock(dataWords, offset);
|
|
259
|
+
}
|
|
260
|
+
processedWords = dataWords.splice(0, nWordsReady);
|
|
261
|
+
data.sigBytes -= nBytesReady;
|
|
262
|
+
}
|
|
263
|
+
return new WordArray.init(processedWords, nBytesReady);
|
|
264
|
+
},
|
|
265
|
+
clone: function() {
|
|
266
|
+
var clone = Base.clone.call(this);
|
|
267
|
+
clone._data = this._data.clone();
|
|
268
|
+
return clone;
|
|
269
|
+
},
|
|
270
|
+
_minBufferSize: 0
|
|
271
|
+
});
|
|
272
|
+
var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
|
|
273
|
+
cfg: Base.extend(),
|
|
274
|
+
init: function(cfg) {
|
|
275
|
+
this.cfg = this.cfg.extend(cfg);
|
|
276
|
+
this.reset();
|
|
277
|
+
},
|
|
278
|
+
reset: function() {
|
|
279
|
+
BufferedBlockAlgorithm.reset.call(this);
|
|
280
|
+
this._doReset();
|
|
281
|
+
},
|
|
282
|
+
update: function(messageUpdate) {
|
|
283
|
+
this._append(messageUpdate);
|
|
284
|
+
this._process();
|
|
285
|
+
return this;
|
|
286
|
+
},
|
|
287
|
+
finalize: function(messageUpdate) {
|
|
288
|
+
if (messageUpdate) {
|
|
289
|
+
this._append(messageUpdate);
|
|
290
|
+
}
|
|
291
|
+
var hash = this._doFinalize();
|
|
292
|
+
return hash;
|
|
293
|
+
},
|
|
294
|
+
blockSize: 512 / 32,
|
|
295
|
+
_createHelper: function(hasher) {
|
|
296
|
+
return function(message, cfg) {
|
|
297
|
+
return new hasher.init(cfg).finalize(message);
|
|
298
|
+
};
|
|
299
|
+
},
|
|
300
|
+
_createHmacHelper: function(hasher) {
|
|
301
|
+
return function(message, key) {
|
|
302
|
+
return new C_algo.HMAC.init(hasher, key).finalize(message);
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
var C_algo = C.algo = {};
|
|
307
|
+
return C;
|
|
308
|
+
}(Math);
|
|
309
|
+
return CryptoJS;
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
// /Users/chrisbreuer/Code/stacks/node_modules/crypto-js/enc-utf8.js
|
|
314
|
+
var require_enc_utf8 = __commonJS((exports, module) => {
|
|
315
|
+
(function(root, factory) {
|
|
316
|
+
if (typeof exports === "object") {
|
|
317
|
+
module.exports = exports = factory(require_core());
|
|
318
|
+
} else if (typeof define === "function" && define.amd) {
|
|
319
|
+
define(["./core"], factory);
|
|
320
|
+
} else {
|
|
321
|
+
factory(root.CryptoJS);
|
|
322
|
+
}
|
|
323
|
+
})(exports, function(CryptoJS) {
|
|
324
|
+
return CryptoJS.enc.Utf8;
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
// /Users/chrisbreuer/Code/stacks/node_modules/crypto-js/enc-base64.js
|
|
329
|
+
var require_enc_base64 = __commonJS((exports, module) => {
|
|
330
|
+
(function(root, factory) {
|
|
331
|
+
if (typeof exports === "object") {
|
|
332
|
+
module.exports = exports = factory(require_core());
|
|
333
|
+
} else if (typeof define === "function" && define.amd) {
|
|
334
|
+
define(["./core"], factory);
|
|
335
|
+
} else {
|
|
336
|
+
factory(root.CryptoJS);
|
|
337
|
+
}
|
|
338
|
+
})(exports, function(CryptoJS) {
|
|
339
|
+
(function() {
|
|
340
|
+
var C = CryptoJS;
|
|
341
|
+
var C_lib = C.lib;
|
|
342
|
+
var WordArray = C_lib.WordArray;
|
|
343
|
+
var C_enc = C.enc;
|
|
344
|
+
var Base64 = C_enc.Base64 = {
|
|
345
|
+
stringify: function(wordArray) {
|
|
346
|
+
var words = wordArray.words;
|
|
347
|
+
var sigBytes = wordArray.sigBytes;
|
|
348
|
+
var map = this._map;
|
|
349
|
+
wordArray.clamp();
|
|
350
|
+
var base64Chars = [];
|
|
351
|
+
for (var i = 0;i < sigBytes; i += 3) {
|
|
352
|
+
var byte1 = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
353
|
+
var byte2 = words[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255;
|
|
354
|
+
var byte3 = words[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255;
|
|
355
|
+
var triplet = byte1 << 16 | byte2 << 8 | byte3;
|
|
356
|
+
for (var j = 0;j < 4 && i + j * 0.75 < sigBytes; j++) {
|
|
357
|
+
base64Chars.push(map.charAt(triplet >>> 6 * (3 - j) & 63));
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
var paddingChar = map.charAt(64);
|
|
361
|
+
if (paddingChar) {
|
|
362
|
+
while (base64Chars.length % 4) {
|
|
363
|
+
base64Chars.push(paddingChar);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
return base64Chars.join("");
|
|
367
|
+
},
|
|
368
|
+
parse: function(base64Str) {
|
|
369
|
+
var base64StrLength = base64Str.length;
|
|
370
|
+
var map = this._map;
|
|
371
|
+
var reverseMap = this._reverseMap;
|
|
372
|
+
if (!reverseMap) {
|
|
373
|
+
reverseMap = this._reverseMap = [];
|
|
374
|
+
for (var j = 0;j < map.length; j++) {
|
|
375
|
+
reverseMap[map.charCodeAt(j)] = j;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
var paddingChar = map.charAt(64);
|
|
379
|
+
if (paddingChar) {
|
|
380
|
+
var paddingIndex = base64Str.indexOf(paddingChar);
|
|
381
|
+
if (paddingIndex !== -1) {
|
|
382
|
+
base64StrLength = paddingIndex;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return parseLoop(base64Str, base64StrLength, reverseMap);
|
|
386
|
+
},
|
|
387
|
+
_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
|
|
388
|
+
};
|
|
389
|
+
function parseLoop(base64Str, base64StrLength, reverseMap) {
|
|
390
|
+
var words = [];
|
|
391
|
+
var nBytes = 0;
|
|
392
|
+
for (var i = 0;i < base64StrLength; i++) {
|
|
393
|
+
if (i % 4) {
|
|
394
|
+
var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << i % 4 * 2;
|
|
395
|
+
var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> 6 - i % 4 * 2;
|
|
396
|
+
var bitsCombined = bits1 | bits2;
|
|
397
|
+
words[nBytes >>> 2] |= bitsCombined << 24 - nBytes % 4 * 8;
|
|
398
|
+
nBytes++;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return WordArray.create(words, nBytes);
|
|
402
|
+
}
|
|
403
|
+
})();
|
|
404
|
+
return CryptoJS.enc.Base64;
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
// /Users/chrisbreuer/Code/stacks/node_modules/crypto-js/md5.js
|
|
409
|
+
var require_md5 = __commonJS((exports, module) => {
|
|
410
|
+
(function(root, factory) {
|
|
411
|
+
if (typeof exports === "object") {
|
|
412
|
+
module.exports = exports = factory(require_core());
|
|
413
|
+
} else if (typeof define === "function" && define.amd) {
|
|
414
|
+
define(["./core"], factory);
|
|
415
|
+
} else {
|
|
416
|
+
factory(root.CryptoJS);
|
|
417
|
+
}
|
|
418
|
+
})(exports, function(CryptoJS) {
|
|
419
|
+
(function(Math2) {
|
|
420
|
+
var C = CryptoJS;
|
|
421
|
+
var C_lib = C.lib;
|
|
422
|
+
var WordArray = C_lib.WordArray;
|
|
423
|
+
var Hasher = C_lib.Hasher;
|
|
424
|
+
var C_algo = C.algo;
|
|
425
|
+
var T = [];
|
|
426
|
+
(function() {
|
|
427
|
+
for (var i = 0;i < 64; i++) {
|
|
428
|
+
T[i] = Math2.abs(Math2.sin(i + 1)) * 4294967296 | 0;
|
|
429
|
+
}
|
|
430
|
+
})();
|
|
431
|
+
var MD5 = C_algo.MD5 = Hasher.extend({
|
|
432
|
+
_doReset: function() {
|
|
433
|
+
this._hash = new WordArray.init([
|
|
434
|
+
1732584193,
|
|
435
|
+
4023233417,
|
|
436
|
+
2562383102,
|
|
437
|
+
271733878
|
|
438
|
+
]);
|
|
439
|
+
},
|
|
440
|
+
_doProcessBlock: function(M, offset) {
|
|
441
|
+
for (var i = 0;i < 16; i++) {
|
|
442
|
+
var offset_i = offset + i;
|
|
443
|
+
var M_offset_i = M[offset_i];
|
|
444
|
+
M[offset_i] = (M_offset_i << 8 | M_offset_i >>> 24) & 16711935 | (M_offset_i << 24 | M_offset_i >>> 8) & 4278255360;
|
|
445
|
+
}
|
|
446
|
+
var H = this._hash.words;
|
|
447
|
+
var M_offset_0 = M[offset + 0];
|
|
448
|
+
var M_offset_1 = M[offset + 1];
|
|
449
|
+
var M_offset_2 = M[offset + 2];
|
|
450
|
+
var M_offset_3 = M[offset + 3];
|
|
451
|
+
var M_offset_4 = M[offset + 4];
|
|
452
|
+
var M_offset_5 = M[offset + 5];
|
|
453
|
+
var M_offset_6 = M[offset + 6];
|
|
454
|
+
var M_offset_7 = M[offset + 7];
|
|
455
|
+
var M_offset_8 = M[offset + 8];
|
|
456
|
+
var M_offset_9 = M[offset + 9];
|
|
457
|
+
var M_offset_10 = M[offset + 10];
|
|
458
|
+
var M_offset_11 = M[offset + 11];
|
|
459
|
+
var M_offset_12 = M[offset + 12];
|
|
460
|
+
var M_offset_13 = M[offset + 13];
|
|
461
|
+
var M_offset_14 = M[offset + 14];
|
|
462
|
+
var M_offset_15 = M[offset + 15];
|
|
463
|
+
var a = H[0];
|
|
464
|
+
var b = H[1];
|
|
465
|
+
var c = H[2];
|
|
466
|
+
var d = H[3];
|
|
467
|
+
a = FF(a, b, c, d, M_offset_0, 7, T[0]);
|
|
468
|
+
d = FF(d, a, b, c, M_offset_1, 12, T[1]);
|
|
469
|
+
c = FF(c, d, a, b, M_offset_2, 17, T[2]);
|
|
470
|
+
b = FF(b, c, d, a, M_offset_3, 22, T[3]);
|
|
471
|
+
a = FF(a, b, c, d, M_offset_4, 7, T[4]);
|
|
472
|
+
d = FF(d, a, b, c, M_offset_5, 12, T[5]);
|
|
473
|
+
c = FF(c, d, a, b, M_offset_6, 17, T[6]);
|
|
474
|
+
b = FF(b, c, d, a, M_offset_7, 22, T[7]);
|
|
475
|
+
a = FF(a, b, c, d, M_offset_8, 7, T[8]);
|
|
476
|
+
d = FF(d, a, b, c, M_offset_9, 12, T[9]);
|
|
477
|
+
c = FF(c, d, a, b, M_offset_10, 17, T[10]);
|
|
478
|
+
b = FF(b, c, d, a, M_offset_11, 22, T[11]);
|
|
479
|
+
a = FF(a, b, c, d, M_offset_12, 7, T[12]);
|
|
480
|
+
d = FF(d, a, b, c, M_offset_13, 12, T[13]);
|
|
481
|
+
c = FF(c, d, a, b, M_offset_14, 17, T[14]);
|
|
482
|
+
b = FF(b, c, d, a, M_offset_15, 22, T[15]);
|
|
483
|
+
a = GG(a, b, c, d, M_offset_1, 5, T[16]);
|
|
484
|
+
d = GG(d, a, b, c, M_offset_6, 9, T[17]);
|
|
485
|
+
c = GG(c, d, a, b, M_offset_11, 14, T[18]);
|
|
486
|
+
b = GG(b, c, d, a, M_offset_0, 20, T[19]);
|
|
487
|
+
a = GG(a, b, c, d, M_offset_5, 5, T[20]);
|
|
488
|
+
d = GG(d, a, b, c, M_offset_10, 9, T[21]);
|
|
489
|
+
c = GG(c, d, a, b, M_offset_15, 14, T[22]);
|
|
490
|
+
b = GG(b, c, d, a, M_offset_4, 20, T[23]);
|
|
491
|
+
a = GG(a, b, c, d, M_offset_9, 5, T[24]);
|
|
492
|
+
d = GG(d, a, b, c, M_offset_14, 9, T[25]);
|
|
493
|
+
c = GG(c, d, a, b, M_offset_3, 14, T[26]);
|
|
494
|
+
b = GG(b, c, d, a, M_offset_8, 20, T[27]);
|
|
495
|
+
a = GG(a, b, c, d, M_offset_13, 5, T[28]);
|
|
496
|
+
d = GG(d, a, b, c, M_offset_2, 9, T[29]);
|
|
497
|
+
c = GG(c, d, a, b, M_offset_7, 14, T[30]);
|
|
498
|
+
b = GG(b, c, d, a, M_offset_12, 20, T[31]);
|
|
499
|
+
a = HH(a, b, c, d, M_offset_5, 4, T[32]);
|
|
500
|
+
d = HH(d, a, b, c, M_offset_8, 11, T[33]);
|
|
501
|
+
c = HH(c, d, a, b, M_offset_11, 16, T[34]);
|
|
502
|
+
b = HH(b, c, d, a, M_offset_14, 23, T[35]);
|
|
503
|
+
a = HH(a, b, c, d, M_offset_1, 4, T[36]);
|
|
504
|
+
d = HH(d, a, b, c, M_offset_4, 11, T[37]);
|
|
505
|
+
c = HH(c, d, a, b, M_offset_7, 16, T[38]);
|
|
506
|
+
b = HH(b, c, d, a, M_offset_10, 23, T[39]);
|
|
507
|
+
a = HH(a, b, c, d, M_offset_13, 4, T[40]);
|
|
508
|
+
d = HH(d, a, b, c, M_offset_0, 11, T[41]);
|
|
509
|
+
c = HH(c, d, a, b, M_offset_3, 16, T[42]);
|
|
510
|
+
b = HH(b, c, d, a, M_offset_6, 23, T[43]);
|
|
511
|
+
a = HH(a, b, c, d, M_offset_9, 4, T[44]);
|
|
512
|
+
d = HH(d, a, b, c, M_offset_12, 11, T[45]);
|
|
513
|
+
c = HH(c, d, a, b, M_offset_15, 16, T[46]);
|
|
514
|
+
b = HH(b, c, d, a, M_offset_2, 23, T[47]);
|
|
515
|
+
a = II(a, b, c, d, M_offset_0, 6, T[48]);
|
|
516
|
+
d = II(d, a, b, c, M_offset_7, 10, T[49]);
|
|
517
|
+
c = II(c, d, a, b, M_offset_14, 15, T[50]);
|
|
518
|
+
b = II(b, c, d, a, M_offset_5, 21, T[51]);
|
|
519
|
+
a = II(a, b, c, d, M_offset_12, 6, T[52]);
|
|
520
|
+
d = II(d, a, b, c, M_offset_3, 10, T[53]);
|
|
521
|
+
c = II(c, d, a, b, M_offset_10, 15, T[54]);
|
|
522
|
+
b = II(b, c, d, a, M_offset_1, 21, T[55]);
|
|
523
|
+
a = II(a, b, c, d, M_offset_8, 6, T[56]);
|
|
524
|
+
d = II(d, a, b, c, M_offset_15, 10, T[57]);
|
|
525
|
+
c = II(c, d, a, b, M_offset_6, 15, T[58]);
|
|
526
|
+
b = II(b, c, d, a, M_offset_13, 21, T[59]);
|
|
527
|
+
a = II(a, b, c, d, M_offset_4, 6, T[60]);
|
|
528
|
+
d = II(d, a, b, c, M_offset_11, 10, T[61]);
|
|
529
|
+
c = II(c, d, a, b, M_offset_2, 15, T[62]);
|
|
530
|
+
b = II(b, c, d, a, M_offset_9, 21, T[63]);
|
|
531
|
+
H[0] = H[0] + a | 0;
|
|
532
|
+
H[1] = H[1] + b | 0;
|
|
533
|
+
H[2] = H[2] + c | 0;
|
|
534
|
+
H[3] = H[3] + d | 0;
|
|
535
|
+
},
|
|
536
|
+
_doFinalize: function() {
|
|
537
|
+
var data = this._data;
|
|
538
|
+
var dataWords = data.words;
|
|
539
|
+
var nBitsTotal = this._nDataBytes * 8;
|
|
540
|
+
var nBitsLeft = data.sigBytes * 8;
|
|
541
|
+
dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
|
|
542
|
+
var nBitsTotalH = Math2.floor(nBitsTotal / 4294967296);
|
|
543
|
+
var nBitsTotalL = nBitsTotal;
|
|
544
|
+
dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = (nBitsTotalH << 8 | nBitsTotalH >>> 24) & 16711935 | (nBitsTotalH << 24 | nBitsTotalH >>> 8) & 4278255360;
|
|
545
|
+
dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = (nBitsTotalL << 8 | nBitsTotalL >>> 24) & 16711935 | (nBitsTotalL << 24 | nBitsTotalL >>> 8) & 4278255360;
|
|
546
|
+
data.sigBytes = (dataWords.length + 1) * 4;
|
|
547
|
+
this._process();
|
|
548
|
+
var hash = this._hash;
|
|
549
|
+
var H = hash.words;
|
|
550
|
+
for (var i = 0;i < 4; i++) {
|
|
551
|
+
var H_i = H[i];
|
|
552
|
+
H[i] = (H_i << 8 | H_i >>> 24) & 16711935 | (H_i << 24 | H_i >>> 8) & 4278255360;
|
|
553
|
+
}
|
|
554
|
+
return hash;
|
|
555
|
+
},
|
|
556
|
+
clone: function() {
|
|
557
|
+
var clone = Hasher.clone.call(this);
|
|
558
|
+
clone._hash = this._hash.clone();
|
|
559
|
+
return clone;
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
function FF(a, b, c, d, x, s, t) {
|
|
563
|
+
var n = a + (b & c | ~b & d) + x + t;
|
|
564
|
+
return (n << s | n >>> 32 - s) + b;
|
|
565
|
+
}
|
|
566
|
+
function GG(a, b, c, d, x, s, t) {
|
|
567
|
+
var n = a + (b & d | c & ~d) + x + t;
|
|
568
|
+
return (n << s | n >>> 32 - s) + b;
|
|
569
|
+
}
|
|
570
|
+
function HH(a, b, c, d, x, s, t) {
|
|
571
|
+
var n = a + (b ^ c ^ d) + x + t;
|
|
572
|
+
return (n << s | n >>> 32 - s) + b;
|
|
573
|
+
}
|
|
574
|
+
function II(a, b, c, d, x, s, t) {
|
|
575
|
+
var n = a + (c ^ (b | ~d)) + x + t;
|
|
576
|
+
return (n << s | n >>> 32 - s) + b;
|
|
577
|
+
}
|
|
578
|
+
C.MD5 = Hasher._createHelper(MD5);
|
|
579
|
+
C.HmacMD5 = Hasher._createHmacHelper(MD5);
|
|
580
|
+
})(Math);
|
|
581
|
+
return CryptoJS.MD5;
|
|
582
|
+
});
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
// /Users/chrisbreuer/Code/stacks/node_modules/crypto-js/sha1.js
|
|
586
|
+
var require_sha1 = __commonJS((exports, module) => {
|
|
587
|
+
(function(root, factory) {
|
|
588
|
+
if (typeof exports === "object") {
|
|
589
|
+
module.exports = exports = factory(require_core());
|
|
590
|
+
} else if (typeof define === "function" && define.amd) {
|
|
591
|
+
define(["./core"], factory);
|
|
592
|
+
} else {
|
|
593
|
+
factory(root.CryptoJS);
|
|
594
|
+
}
|
|
595
|
+
})(exports, function(CryptoJS) {
|
|
596
|
+
(function() {
|
|
597
|
+
var C = CryptoJS;
|
|
598
|
+
var C_lib = C.lib;
|
|
599
|
+
var WordArray = C_lib.WordArray;
|
|
600
|
+
var Hasher = C_lib.Hasher;
|
|
601
|
+
var C_algo = C.algo;
|
|
602
|
+
var W = [];
|
|
603
|
+
var SHA1 = C_algo.SHA1 = Hasher.extend({
|
|
604
|
+
_doReset: function() {
|
|
605
|
+
this._hash = new WordArray.init([
|
|
606
|
+
1732584193,
|
|
607
|
+
4023233417,
|
|
608
|
+
2562383102,
|
|
609
|
+
271733878,
|
|
610
|
+
3285377520
|
|
611
|
+
]);
|
|
612
|
+
},
|
|
613
|
+
_doProcessBlock: function(M, offset) {
|
|
614
|
+
var H = this._hash.words;
|
|
615
|
+
var a = H[0];
|
|
616
|
+
var b = H[1];
|
|
617
|
+
var c = H[2];
|
|
618
|
+
var d = H[3];
|
|
619
|
+
var e = H[4];
|
|
620
|
+
for (var i = 0;i < 80; i++) {
|
|
621
|
+
if (i < 16) {
|
|
622
|
+
W[i] = M[offset + i] | 0;
|
|
623
|
+
} else {
|
|
624
|
+
var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
|
|
625
|
+
W[i] = n << 1 | n >>> 31;
|
|
626
|
+
}
|
|
627
|
+
var t = (a << 5 | a >>> 27) + e + W[i];
|
|
628
|
+
if (i < 20) {
|
|
629
|
+
t += (b & c | ~b & d) + 1518500249;
|
|
630
|
+
} else if (i < 40) {
|
|
631
|
+
t += (b ^ c ^ d) + 1859775393;
|
|
632
|
+
} else if (i < 60) {
|
|
633
|
+
t += (b & c | b & d | c & d) - 1894007588;
|
|
634
|
+
} else {
|
|
635
|
+
t += (b ^ c ^ d) - 899497514;
|
|
636
|
+
}
|
|
637
|
+
e = d;
|
|
638
|
+
d = c;
|
|
639
|
+
c = b << 30 | b >>> 2;
|
|
640
|
+
b = a;
|
|
641
|
+
a = t;
|
|
642
|
+
}
|
|
643
|
+
H[0] = H[0] + a | 0;
|
|
644
|
+
H[1] = H[1] + b | 0;
|
|
645
|
+
H[2] = H[2] + c | 0;
|
|
646
|
+
H[3] = H[3] + d | 0;
|
|
647
|
+
H[4] = H[4] + e | 0;
|
|
648
|
+
},
|
|
649
|
+
_doFinalize: function() {
|
|
650
|
+
var data = this._data;
|
|
651
|
+
var dataWords = data.words;
|
|
652
|
+
var nBitsTotal = this._nDataBytes * 8;
|
|
653
|
+
var nBitsLeft = data.sigBytes * 8;
|
|
654
|
+
dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
|
|
655
|
+
dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = Math.floor(nBitsTotal / 4294967296);
|
|
656
|
+
dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = nBitsTotal;
|
|
657
|
+
data.sigBytes = dataWords.length * 4;
|
|
658
|
+
this._process();
|
|
659
|
+
return this._hash;
|
|
660
|
+
},
|
|
661
|
+
clone: function() {
|
|
662
|
+
var clone = Hasher.clone.call(this);
|
|
663
|
+
clone._hash = this._hash.clone();
|
|
664
|
+
return clone;
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
C.SHA1 = Hasher._createHelper(SHA1);
|
|
668
|
+
C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
|
|
669
|
+
})();
|
|
670
|
+
return CryptoJS.SHA1;
|
|
671
|
+
});
|
|
672
|
+
});
|
|
673
|
+
|
|
674
|
+
// /Users/chrisbreuer/Code/stacks/node_modules/crypto-js/hmac.js
|
|
675
|
+
var require_hmac = __commonJS((exports, module) => {
|
|
676
|
+
(function(root, factory) {
|
|
677
|
+
if (typeof exports === "object") {
|
|
678
|
+
module.exports = exports = factory(require_core());
|
|
679
|
+
} else if (typeof define === "function" && define.amd) {
|
|
680
|
+
define(["./core"], factory);
|
|
681
|
+
} else {
|
|
682
|
+
factory(root.CryptoJS);
|
|
683
|
+
}
|
|
684
|
+
})(exports, function(CryptoJS) {
|
|
685
|
+
(function() {
|
|
686
|
+
var C = CryptoJS;
|
|
687
|
+
var C_lib = C.lib;
|
|
688
|
+
var Base = C_lib.Base;
|
|
689
|
+
var C_enc = C.enc;
|
|
690
|
+
var Utf8 = C_enc.Utf8;
|
|
691
|
+
var C_algo = C.algo;
|
|
692
|
+
var HMAC = C_algo.HMAC = Base.extend({
|
|
693
|
+
init: function(hasher, key) {
|
|
694
|
+
hasher = this._hasher = new hasher.init;
|
|
695
|
+
if (typeof key == "string") {
|
|
696
|
+
key = Utf8.parse(key);
|
|
697
|
+
}
|
|
698
|
+
var hasherBlockSize = hasher.blockSize;
|
|
699
|
+
var hasherBlockSizeBytes = hasherBlockSize * 4;
|
|
700
|
+
if (key.sigBytes > hasherBlockSizeBytes) {
|
|
701
|
+
key = hasher.finalize(key);
|
|
702
|
+
}
|
|
703
|
+
key.clamp();
|
|
704
|
+
var oKey = this._oKey = key.clone();
|
|
705
|
+
var iKey = this._iKey = key.clone();
|
|
706
|
+
var oKeyWords = oKey.words;
|
|
707
|
+
var iKeyWords = iKey.words;
|
|
708
|
+
for (var i = 0;i < hasherBlockSize; i++) {
|
|
709
|
+
oKeyWords[i] ^= 1549556828;
|
|
710
|
+
iKeyWords[i] ^= 909522486;
|
|
711
|
+
}
|
|
712
|
+
oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
|
|
713
|
+
this.reset();
|
|
714
|
+
},
|
|
715
|
+
reset: function() {
|
|
716
|
+
var hasher = this._hasher;
|
|
717
|
+
hasher.reset();
|
|
718
|
+
hasher.update(this._iKey);
|
|
719
|
+
},
|
|
720
|
+
update: function(messageUpdate) {
|
|
721
|
+
this._hasher.update(messageUpdate);
|
|
722
|
+
return this;
|
|
723
|
+
},
|
|
724
|
+
finalize: function(messageUpdate) {
|
|
725
|
+
var hasher = this._hasher;
|
|
726
|
+
var innerHash = hasher.finalize(messageUpdate);
|
|
727
|
+
hasher.reset();
|
|
728
|
+
var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
|
|
729
|
+
return hmac;
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
})();
|
|
733
|
+
});
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
// /Users/chrisbreuer/Code/stacks/node_modules/crypto-js/evpkdf.js
|
|
737
|
+
var require_evpkdf = __commonJS((exports, module) => {
|
|
738
|
+
(function(root, factory, undef) {
|
|
739
|
+
if (typeof exports === "object") {
|
|
740
|
+
module.exports = exports = factory(require_core(), require_sha1(), require_hmac());
|
|
741
|
+
} else if (typeof define === "function" && define.amd) {
|
|
742
|
+
define(["./core", "./sha1", "./hmac"], factory);
|
|
743
|
+
} else {
|
|
744
|
+
factory(root.CryptoJS);
|
|
745
|
+
}
|
|
746
|
+
})(exports, function(CryptoJS) {
|
|
747
|
+
(function() {
|
|
748
|
+
var C = CryptoJS;
|
|
749
|
+
var C_lib = C.lib;
|
|
750
|
+
var Base = C_lib.Base;
|
|
751
|
+
var WordArray = C_lib.WordArray;
|
|
752
|
+
var C_algo = C.algo;
|
|
753
|
+
var MD5 = C_algo.MD5;
|
|
754
|
+
var EvpKDF = C_algo.EvpKDF = Base.extend({
|
|
755
|
+
cfg: Base.extend({
|
|
756
|
+
keySize: 128 / 32,
|
|
757
|
+
hasher: MD5,
|
|
758
|
+
iterations: 1
|
|
759
|
+
}),
|
|
760
|
+
init: function(cfg) {
|
|
761
|
+
this.cfg = this.cfg.extend(cfg);
|
|
762
|
+
},
|
|
763
|
+
compute: function(password, salt) {
|
|
764
|
+
var block;
|
|
765
|
+
var cfg = this.cfg;
|
|
766
|
+
var hasher = cfg.hasher.create();
|
|
767
|
+
var derivedKey = WordArray.create();
|
|
768
|
+
var derivedKeyWords = derivedKey.words;
|
|
769
|
+
var keySize = cfg.keySize;
|
|
770
|
+
var iterations = cfg.iterations;
|
|
771
|
+
while (derivedKeyWords.length < keySize) {
|
|
772
|
+
if (block) {
|
|
773
|
+
hasher.update(block);
|
|
774
|
+
}
|
|
775
|
+
block = hasher.update(password).finalize(salt);
|
|
776
|
+
hasher.reset();
|
|
777
|
+
for (var i = 1;i < iterations; i++) {
|
|
778
|
+
block = hasher.finalize(block);
|
|
779
|
+
hasher.reset();
|
|
780
|
+
}
|
|
781
|
+
derivedKey.concat(block);
|
|
782
|
+
}
|
|
783
|
+
derivedKey.sigBytes = keySize * 4;
|
|
784
|
+
return derivedKey;
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
C.EvpKDF = function(password, salt, cfg) {
|
|
788
|
+
return EvpKDF.create(cfg).compute(password, salt);
|
|
789
|
+
};
|
|
790
|
+
})();
|
|
791
|
+
return CryptoJS.EvpKDF;
|
|
792
|
+
});
|
|
793
|
+
});
|
|
794
|
+
|
|
795
|
+
// /Users/chrisbreuer/Code/stacks/node_modules/crypto-js/cipher-core.js
|
|
796
|
+
var require_cipher_core = __commonJS((exports, module) => {
|
|
797
|
+
(function(root, factory, undef) {
|
|
798
|
+
if (typeof exports === "object") {
|
|
799
|
+
module.exports = exports = factory(require_core(), require_evpkdf());
|
|
800
|
+
} else if (typeof define === "function" && define.amd) {
|
|
801
|
+
define(["./core", "./evpkdf"], factory);
|
|
802
|
+
} else {
|
|
803
|
+
factory(root.CryptoJS);
|
|
804
|
+
}
|
|
805
|
+
})(exports, function(CryptoJS) {
|
|
806
|
+
CryptoJS.lib.Cipher || function(undefined2) {
|
|
807
|
+
var C = CryptoJS;
|
|
808
|
+
var C_lib = C.lib;
|
|
809
|
+
var Base = C_lib.Base;
|
|
810
|
+
var WordArray = C_lib.WordArray;
|
|
811
|
+
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
|
|
812
|
+
var C_enc = C.enc;
|
|
813
|
+
var Utf8 = C_enc.Utf8;
|
|
814
|
+
var Base64 = C_enc.Base64;
|
|
815
|
+
var C_algo = C.algo;
|
|
816
|
+
var EvpKDF = C_algo.EvpKDF;
|
|
817
|
+
var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
|
|
818
|
+
cfg: Base.extend(),
|
|
819
|
+
createEncryptor: function(key, cfg) {
|
|
820
|
+
return this.create(this._ENC_XFORM_MODE, key, cfg);
|
|
821
|
+
},
|
|
822
|
+
createDecryptor: function(key, cfg) {
|
|
823
|
+
return this.create(this._DEC_XFORM_MODE, key, cfg);
|
|
824
|
+
},
|
|
825
|
+
init: function(xformMode, key, cfg) {
|
|
826
|
+
this.cfg = this.cfg.extend(cfg);
|
|
827
|
+
this._xformMode = xformMode;
|
|
828
|
+
this._key = key;
|
|
829
|
+
this.reset();
|
|
830
|
+
},
|
|
831
|
+
reset: function() {
|
|
832
|
+
BufferedBlockAlgorithm.reset.call(this);
|
|
833
|
+
this._doReset();
|
|
834
|
+
},
|
|
835
|
+
process: function(dataUpdate) {
|
|
836
|
+
this._append(dataUpdate);
|
|
837
|
+
return this._process();
|
|
838
|
+
},
|
|
839
|
+
finalize: function(dataUpdate) {
|
|
840
|
+
if (dataUpdate) {
|
|
841
|
+
this._append(dataUpdate);
|
|
842
|
+
}
|
|
843
|
+
var finalProcessedData = this._doFinalize();
|
|
844
|
+
return finalProcessedData;
|
|
845
|
+
},
|
|
846
|
+
keySize: 128 / 32,
|
|
847
|
+
ivSize: 128 / 32,
|
|
848
|
+
_ENC_XFORM_MODE: 1,
|
|
849
|
+
_DEC_XFORM_MODE: 2,
|
|
850
|
+
_createHelper: function() {
|
|
851
|
+
function selectCipherStrategy(key) {
|
|
852
|
+
if (typeof key == "string") {
|
|
853
|
+
return PasswordBasedCipher;
|
|
854
|
+
} else {
|
|
855
|
+
return SerializableCipher;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
return function(cipher) {
|
|
859
|
+
return {
|
|
860
|
+
encrypt: function(message, key, cfg) {
|
|
861
|
+
return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
|
|
862
|
+
},
|
|
863
|
+
decrypt: function(ciphertext, key, cfg) {
|
|
864
|
+
return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
};
|
|
868
|
+
}()
|
|
869
|
+
});
|
|
870
|
+
var StreamCipher = C_lib.StreamCipher = Cipher.extend({
|
|
871
|
+
_doFinalize: function() {
|
|
872
|
+
var finalProcessedBlocks = this._process(true);
|
|
873
|
+
return finalProcessedBlocks;
|
|
874
|
+
},
|
|
875
|
+
blockSize: 1
|
|
876
|
+
});
|
|
877
|
+
var C_mode = C.mode = {};
|
|
878
|
+
var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
|
|
879
|
+
createEncryptor: function(cipher, iv) {
|
|
880
|
+
return this.Encryptor.create(cipher, iv);
|
|
881
|
+
},
|
|
882
|
+
createDecryptor: function(cipher, iv) {
|
|
883
|
+
return this.Decryptor.create(cipher, iv);
|
|
884
|
+
},
|
|
885
|
+
init: function(cipher, iv) {
|
|
886
|
+
this._cipher = cipher;
|
|
887
|
+
this._iv = iv;
|
|
888
|
+
}
|
|
889
|
+
});
|
|
890
|
+
var CBC = C_mode.CBC = function() {
|
|
891
|
+
var CBC2 = BlockCipherMode.extend();
|
|
892
|
+
CBC2.Encryptor = CBC2.extend({
|
|
893
|
+
processBlock: function(words, offset) {
|
|
894
|
+
var cipher = this._cipher;
|
|
895
|
+
var blockSize = cipher.blockSize;
|
|
896
|
+
xorBlock.call(this, words, offset, blockSize);
|
|
897
|
+
cipher.encryptBlock(words, offset);
|
|
898
|
+
this._prevBlock = words.slice(offset, offset + blockSize);
|
|
899
|
+
}
|
|
900
|
+
});
|
|
901
|
+
CBC2.Decryptor = CBC2.extend({
|
|
902
|
+
processBlock: function(words, offset) {
|
|
903
|
+
var cipher = this._cipher;
|
|
904
|
+
var blockSize = cipher.blockSize;
|
|
905
|
+
var thisBlock = words.slice(offset, offset + blockSize);
|
|
906
|
+
cipher.decryptBlock(words, offset);
|
|
907
|
+
xorBlock.call(this, words, offset, blockSize);
|
|
908
|
+
this._prevBlock = thisBlock;
|
|
909
|
+
}
|
|
910
|
+
});
|
|
911
|
+
function xorBlock(words, offset, blockSize) {
|
|
912
|
+
var block;
|
|
913
|
+
var iv = this._iv;
|
|
914
|
+
if (iv) {
|
|
915
|
+
block = iv;
|
|
916
|
+
this._iv = undefined2;
|
|
917
|
+
} else {
|
|
918
|
+
block = this._prevBlock;
|
|
919
|
+
}
|
|
920
|
+
for (var i = 0;i < blockSize; i++) {
|
|
921
|
+
words[offset + i] ^= block[i];
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
return CBC2;
|
|
925
|
+
}();
|
|
926
|
+
var C_pad = C.pad = {};
|
|
927
|
+
var Pkcs7 = C_pad.Pkcs7 = {
|
|
928
|
+
pad: function(data, blockSize) {
|
|
929
|
+
var blockSizeBytes = blockSize * 4;
|
|
930
|
+
var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
|
|
931
|
+
var paddingWord = nPaddingBytes << 24 | nPaddingBytes << 16 | nPaddingBytes << 8 | nPaddingBytes;
|
|
932
|
+
var paddingWords = [];
|
|
933
|
+
for (var i = 0;i < nPaddingBytes; i += 4) {
|
|
934
|
+
paddingWords.push(paddingWord);
|
|
935
|
+
}
|
|
936
|
+
var padding = WordArray.create(paddingWords, nPaddingBytes);
|
|
937
|
+
data.concat(padding);
|
|
938
|
+
},
|
|
939
|
+
unpad: function(data) {
|
|
940
|
+
var nPaddingBytes = data.words[data.sigBytes - 1 >>> 2] & 255;
|
|
941
|
+
data.sigBytes -= nPaddingBytes;
|
|
942
|
+
}
|
|
943
|
+
};
|
|
944
|
+
var BlockCipher = C_lib.BlockCipher = Cipher.extend({
|
|
945
|
+
cfg: Cipher.cfg.extend({
|
|
946
|
+
mode: CBC,
|
|
947
|
+
padding: Pkcs7
|
|
948
|
+
}),
|
|
949
|
+
reset: function() {
|
|
950
|
+
var modeCreator;
|
|
951
|
+
Cipher.reset.call(this);
|
|
952
|
+
var cfg = this.cfg;
|
|
953
|
+
var iv = cfg.iv;
|
|
954
|
+
var mode = cfg.mode;
|
|
955
|
+
if (this._xformMode == this._ENC_XFORM_MODE) {
|
|
956
|
+
modeCreator = mode.createEncryptor;
|
|
957
|
+
} else {
|
|
958
|
+
modeCreator = mode.createDecryptor;
|
|
959
|
+
this._minBufferSize = 1;
|
|
960
|
+
}
|
|
961
|
+
if (this._mode && this._mode.__creator == modeCreator) {
|
|
962
|
+
this._mode.init(this, iv && iv.words);
|
|
963
|
+
} else {
|
|
964
|
+
this._mode = modeCreator.call(mode, this, iv && iv.words);
|
|
965
|
+
this._mode.__creator = modeCreator;
|
|
966
|
+
}
|
|
967
|
+
},
|
|
968
|
+
_doProcessBlock: function(words, offset) {
|
|
969
|
+
this._mode.processBlock(words, offset);
|
|
970
|
+
},
|
|
971
|
+
_doFinalize: function() {
|
|
972
|
+
var finalProcessedBlocks;
|
|
973
|
+
var padding = this.cfg.padding;
|
|
974
|
+
if (this._xformMode == this._ENC_XFORM_MODE) {
|
|
975
|
+
padding.pad(this._data, this.blockSize);
|
|
976
|
+
finalProcessedBlocks = this._process(true);
|
|
977
|
+
} else {
|
|
978
|
+
finalProcessedBlocks = this._process(true);
|
|
979
|
+
padding.unpad(finalProcessedBlocks);
|
|
980
|
+
}
|
|
981
|
+
return finalProcessedBlocks;
|
|
982
|
+
},
|
|
983
|
+
blockSize: 128 / 32
|
|
984
|
+
});
|
|
985
|
+
var CipherParams = C_lib.CipherParams = Base.extend({
|
|
986
|
+
init: function(cipherParams) {
|
|
987
|
+
this.mixIn(cipherParams);
|
|
988
|
+
},
|
|
989
|
+
toString: function(formatter) {
|
|
990
|
+
return (formatter || this.formatter).stringify(this);
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
var C_format = C.format = {};
|
|
994
|
+
var OpenSSLFormatter = C_format.OpenSSL = {
|
|
995
|
+
stringify: function(cipherParams) {
|
|
996
|
+
var wordArray;
|
|
997
|
+
var ciphertext = cipherParams.ciphertext;
|
|
998
|
+
var salt = cipherParams.salt;
|
|
999
|
+
if (salt) {
|
|
1000
|
+
wordArray = WordArray.create([1398893684, 1701076831]).concat(salt).concat(ciphertext);
|
|
1001
|
+
} else {
|
|
1002
|
+
wordArray = ciphertext;
|
|
1003
|
+
}
|
|
1004
|
+
return wordArray.toString(Base64);
|
|
1005
|
+
},
|
|
1006
|
+
parse: function(openSSLStr) {
|
|
1007
|
+
var salt;
|
|
1008
|
+
var ciphertext = Base64.parse(openSSLStr);
|
|
1009
|
+
var ciphertextWords = ciphertext.words;
|
|
1010
|
+
if (ciphertextWords[0] == 1398893684 && ciphertextWords[1] == 1701076831) {
|
|
1011
|
+
salt = WordArray.create(ciphertextWords.slice(2, 4));
|
|
1012
|
+
ciphertextWords.splice(0, 4);
|
|
1013
|
+
ciphertext.sigBytes -= 16;
|
|
1014
|
+
}
|
|
1015
|
+
return CipherParams.create({ ciphertext, salt });
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1018
|
+
var SerializableCipher = C_lib.SerializableCipher = Base.extend({
|
|
1019
|
+
cfg: Base.extend({
|
|
1020
|
+
format: OpenSSLFormatter
|
|
1021
|
+
}),
|
|
1022
|
+
encrypt: function(cipher, message, key, cfg) {
|
|
1023
|
+
cfg = this.cfg.extend(cfg);
|
|
1024
|
+
var encryptor = cipher.createEncryptor(key, cfg);
|
|
1025
|
+
var ciphertext = encryptor.finalize(message);
|
|
1026
|
+
var cipherCfg = encryptor.cfg;
|
|
1027
|
+
return CipherParams.create({
|
|
1028
|
+
ciphertext,
|
|
1029
|
+
key,
|
|
1030
|
+
iv: cipherCfg.iv,
|
|
1031
|
+
algorithm: cipher,
|
|
1032
|
+
mode: cipherCfg.mode,
|
|
1033
|
+
padding: cipherCfg.padding,
|
|
1034
|
+
blockSize: cipher.blockSize,
|
|
1035
|
+
formatter: cfg.format
|
|
1036
|
+
});
|
|
1037
|
+
},
|
|
1038
|
+
decrypt: function(cipher, ciphertext, key, cfg) {
|
|
1039
|
+
cfg = this.cfg.extend(cfg);
|
|
1040
|
+
ciphertext = this._parse(ciphertext, cfg.format);
|
|
1041
|
+
var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
|
|
1042
|
+
return plaintext;
|
|
1043
|
+
},
|
|
1044
|
+
_parse: function(ciphertext, format) {
|
|
1045
|
+
if (typeof ciphertext == "string") {
|
|
1046
|
+
return format.parse(ciphertext, this);
|
|
1047
|
+
} else {
|
|
1048
|
+
return ciphertext;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
});
|
|
1052
|
+
var C_kdf = C.kdf = {};
|
|
1053
|
+
var OpenSSLKdf = C_kdf.OpenSSL = {
|
|
1054
|
+
execute: function(password, keySize, ivSize, salt, hasher) {
|
|
1055
|
+
if (!salt) {
|
|
1056
|
+
salt = WordArray.random(64 / 8);
|
|
1057
|
+
}
|
|
1058
|
+
if (!hasher) {
|
|
1059
|
+
var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
|
|
1060
|
+
} else {
|
|
1061
|
+
var key = EvpKDF.create({ keySize: keySize + ivSize, hasher }).compute(password, salt);
|
|
1062
|
+
}
|
|
1063
|
+
var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
|
|
1064
|
+
key.sigBytes = keySize * 4;
|
|
1065
|
+
return CipherParams.create({ key, iv, salt });
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
|
|
1069
|
+
cfg: SerializableCipher.cfg.extend({
|
|
1070
|
+
kdf: OpenSSLKdf
|
|
1071
|
+
}),
|
|
1072
|
+
encrypt: function(cipher, message, password, cfg) {
|
|
1073
|
+
cfg = this.cfg.extend(cfg);
|
|
1074
|
+
var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, cfg.salt, cfg.hasher);
|
|
1075
|
+
cfg.iv = derivedParams.iv;
|
|
1076
|
+
var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
|
|
1077
|
+
ciphertext.mixIn(derivedParams);
|
|
1078
|
+
return ciphertext;
|
|
1079
|
+
},
|
|
1080
|
+
decrypt: function(cipher, ciphertext, password, cfg) {
|
|
1081
|
+
cfg = this.cfg.extend(cfg);
|
|
1082
|
+
ciphertext = this._parse(ciphertext, cfg.format);
|
|
1083
|
+
var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt, cfg.hasher);
|
|
1084
|
+
cfg.iv = derivedParams.iv;
|
|
1085
|
+
var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
|
|
1086
|
+
return plaintext;
|
|
1087
|
+
}
|
|
1088
|
+
});
|
|
1089
|
+
}();
|
|
1090
|
+
});
|
|
1091
|
+
});
|
|
1092
|
+
|
|
1093
|
+
// /Users/chrisbreuer/Code/stacks/node_modules/crypto-js/aes.js
|
|
1094
|
+
var require_aes = __commonJS((exports, module) => {
|
|
1095
|
+
(function(root, factory, undef) {
|
|
1096
|
+
if (typeof exports === "object") {
|
|
1097
|
+
module.exports = exports = factory(require_core(), require_enc_base64(), require_md5(), require_evpkdf(), require_cipher_core());
|
|
1098
|
+
} else if (typeof define === "function" && define.amd) {
|
|
1099
|
+
define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
|
|
1100
|
+
} else {
|
|
1101
|
+
factory(root.CryptoJS);
|
|
1102
|
+
}
|
|
1103
|
+
})(exports, function(CryptoJS) {
|
|
1104
|
+
(function() {
|
|
1105
|
+
var C = CryptoJS;
|
|
1106
|
+
var C_lib = C.lib;
|
|
1107
|
+
var BlockCipher = C_lib.BlockCipher;
|
|
1108
|
+
var C_algo = C.algo;
|
|
1109
|
+
var SBOX = [];
|
|
1110
|
+
var INV_SBOX = [];
|
|
1111
|
+
var SUB_MIX_0 = [];
|
|
1112
|
+
var SUB_MIX_1 = [];
|
|
1113
|
+
var SUB_MIX_2 = [];
|
|
1114
|
+
var SUB_MIX_3 = [];
|
|
1115
|
+
var INV_SUB_MIX_0 = [];
|
|
1116
|
+
var INV_SUB_MIX_1 = [];
|
|
1117
|
+
var INV_SUB_MIX_2 = [];
|
|
1118
|
+
var INV_SUB_MIX_3 = [];
|
|
1119
|
+
(function() {
|
|
1120
|
+
var d = [];
|
|
1121
|
+
for (var i = 0;i < 256; i++) {
|
|
1122
|
+
if (i < 128) {
|
|
1123
|
+
d[i] = i << 1;
|
|
1124
|
+
} else {
|
|
1125
|
+
d[i] = i << 1 ^ 283;
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
var x = 0;
|
|
1129
|
+
var xi = 0;
|
|
1130
|
+
for (var i = 0;i < 256; i++) {
|
|
1131
|
+
var sx = xi ^ xi << 1 ^ xi << 2 ^ xi << 3 ^ xi << 4;
|
|
1132
|
+
sx = sx >>> 8 ^ sx & 255 ^ 99;
|
|
1133
|
+
SBOX[x] = sx;
|
|
1134
|
+
INV_SBOX[sx] = x;
|
|
1135
|
+
var x2 = d[x];
|
|
1136
|
+
var x4 = d[x2];
|
|
1137
|
+
var x8 = d[x4];
|
|
1138
|
+
var t = d[sx] * 257 ^ sx * 16843008;
|
|
1139
|
+
SUB_MIX_0[x] = t << 24 | t >>> 8;
|
|
1140
|
+
SUB_MIX_1[x] = t << 16 | t >>> 16;
|
|
1141
|
+
SUB_MIX_2[x] = t << 8 | t >>> 24;
|
|
1142
|
+
SUB_MIX_3[x] = t;
|
|
1143
|
+
var t = x8 * 16843009 ^ x4 * 65537 ^ x2 * 257 ^ x * 16843008;
|
|
1144
|
+
INV_SUB_MIX_0[sx] = t << 24 | t >>> 8;
|
|
1145
|
+
INV_SUB_MIX_1[sx] = t << 16 | t >>> 16;
|
|
1146
|
+
INV_SUB_MIX_2[sx] = t << 8 | t >>> 24;
|
|
1147
|
+
INV_SUB_MIX_3[sx] = t;
|
|
1148
|
+
if (!x) {
|
|
1149
|
+
x = xi = 1;
|
|
1150
|
+
} else {
|
|
1151
|
+
x = x2 ^ d[d[d[x8 ^ x2]]];
|
|
1152
|
+
xi ^= d[d[xi]];
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
})();
|
|
1156
|
+
var RCON = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54];
|
|
1157
|
+
var AES = C_algo.AES = BlockCipher.extend({
|
|
1158
|
+
_doReset: function() {
|
|
1159
|
+
var t;
|
|
1160
|
+
if (this._nRounds && this._keyPriorReset === this._key) {
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
var key = this._keyPriorReset = this._key;
|
|
1164
|
+
var keyWords = key.words;
|
|
1165
|
+
var keySize = key.sigBytes / 4;
|
|
1166
|
+
var nRounds = this._nRounds = keySize + 6;
|
|
1167
|
+
var ksRows = (nRounds + 1) * 4;
|
|
1168
|
+
var keySchedule = this._keySchedule = [];
|
|
1169
|
+
for (var ksRow = 0;ksRow < ksRows; ksRow++) {
|
|
1170
|
+
if (ksRow < keySize) {
|
|
1171
|
+
keySchedule[ksRow] = keyWords[ksRow];
|
|
1172
|
+
} else {
|
|
1173
|
+
t = keySchedule[ksRow - 1];
|
|
1174
|
+
if (!(ksRow % keySize)) {
|
|
1175
|
+
t = t << 8 | t >>> 24;
|
|
1176
|
+
t = SBOX[t >>> 24] << 24 | SBOX[t >>> 16 & 255] << 16 | SBOX[t >>> 8 & 255] << 8 | SBOX[t & 255];
|
|
1177
|
+
t ^= RCON[ksRow / keySize | 0] << 24;
|
|
1178
|
+
} else if (keySize > 6 && ksRow % keySize == 4) {
|
|
1179
|
+
t = SBOX[t >>> 24] << 24 | SBOX[t >>> 16 & 255] << 16 | SBOX[t >>> 8 & 255] << 8 | SBOX[t & 255];
|
|
1180
|
+
}
|
|
1181
|
+
keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
var invKeySchedule = this._invKeySchedule = [];
|
|
1185
|
+
for (var invKsRow = 0;invKsRow < ksRows; invKsRow++) {
|
|
1186
|
+
var ksRow = ksRows - invKsRow;
|
|
1187
|
+
if (invKsRow % 4) {
|
|
1188
|
+
var t = keySchedule[ksRow];
|
|
1189
|
+
} else {
|
|
1190
|
+
var t = keySchedule[ksRow - 4];
|
|
1191
|
+
}
|
|
1192
|
+
if (invKsRow < 4 || ksRow <= 4) {
|
|
1193
|
+
invKeySchedule[invKsRow] = t;
|
|
1194
|
+
} else {
|
|
1195
|
+
invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[t >>> 16 & 255]] ^ INV_SUB_MIX_2[SBOX[t >>> 8 & 255]] ^ INV_SUB_MIX_3[SBOX[t & 255]];
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
},
|
|
1199
|
+
encryptBlock: function(M, offset) {
|
|
1200
|
+
this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
|
|
1201
|
+
},
|
|
1202
|
+
decryptBlock: function(M, offset) {
|
|
1203
|
+
var t = M[offset + 1];
|
|
1204
|
+
M[offset + 1] = M[offset + 3];
|
|
1205
|
+
M[offset + 3] = t;
|
|
1206
|
+
this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
|
|
1207
|
+
var t = M[offset + 1];
|
|
1208
|
+
M[offset + 1] = M[offset + 3];
|
|
1209
|
+
M[offset + 3] = t;
|
|
1210
|
+
},
|
|
1211
|
+
_doCryptBlock: function(M, offset, keySchedule, SUB_MIX_02, SUB_MIX_12, SUB_MIX_22, SUB_MIX_32, SBOX2) {
|
|
1212
|
+
var nRounds = this._nRounds;
|
|
1213
|
+
var s0 = M[offset] ^ keySchedule[0];
|
|
1214
|
+
var s1 = M[offset + 1] ^ keySchedule[1];
|
|
1215
|
+
var s2 = M[offset + 2] ^ keySchedule[2];
|
|
1216
|
+
var s3 = M[offset + 3] ^ keySchedule[3];
|
|
1217
|
+
var ksRow = 4;
|
|
1218
|
+
for (var round = 1;round < nRounds; round++) {
|
|
1219
|
+
var t0 = SUB_MIX_02[s0 >>> 24] ^ SUB_MIX_12[s1 >>> 16 & 255] ^ SUB_MIX_22[s2 >>> 8 & 255] ^ SUB_MIX_32[s3 & 255] ^ keySchedule[ksRow++];
|
|
1220
|
+
var t1 = SUB_MIX_02[s1 >>> 24] ^ SUB_MIX_12[s2 >>> 16 & 255] ^ SUB_MIX_22[s3 >>> 8 & 255] ^ SUB_MIX_32[s0 & 255] ^ keySchedule[ksRow++];
|
|
1221
|
+
var t2 = SUB_MIX_02[s2 >>> 24] ^ SUB_MIX_12[s3 >>> 16 & 255] ^ SUB_MIX_22[s0 >>> 8 & 255] ^ SUB_MIX_32[s1 & 255] ^ keySchedule[ksRow++];
|
|
1222
|
+
var t3 = SUB_MIX_02[s3 >>> 24] ^ SUB_MIX_12[s0 >>> 16 & 255] ^ SUB_MIX_22[s1 >>> 8 & 255] ^ SUB_MIX_32[s2 & 255] ^ keySchedule[ksRow++];
|
|
1223
|
+
s0 = t0;
|
|
1224
|
+
s1 = t1;
|
|
1225
|
+
s2 = t2;
|
|
1226
|
+
s3 = t3;
|
|
1227
|
+
}
|
|
1228
|
+
var t0 = (SBOX2[s0 >>> 24] << 24 | SBOX2[s1 >>> 16 & 255] << 16 | SBOX2[s2 >>> 8 & 255] << 8 | SBOX2[s3 & 255]) ^ keySchedule[ksRow++];
|
|
1229
|
+
var t1 = (SBOX2[s1 >>> 24] << 24 | SBOX2[s2 >>> 16 & 255] << 16 | SBOX2[s3 >>> 8 & 255] << 8 | SBOX2[s0 & 255]) ^ keySchedule[ksRow++];
|
|
1230
|
+
var t2 = (SBOX2[s2 >>> 24] << 24 | SBOX2[s3 >>> 16 & 255] << 16 | SBOX2[s0 >>> 8 & 255] << 8 | SBOX2[s1 & 255]) ^ keySchedule[ksRow++];
|
|
1231
|
+
var t3 = (SBOX2[s3 >>> 24] << 24 | SBOX2[s0 >>> 16 & 255] << 16 | SBOX2[s1 >>> 8 & 255] << 8 | SBOX2[s2 & 255]) ^ keySchedule[ksRow++];
|
|
1232
|
+
M[offset] = t0;
|
|
1233
|
+
M[offset + 1] = t1;
|
|
1234
|
+
M[offset + 2] = t2;
|
|
1235
|
+
M[offset + 3] = t3;
|
|
1236
|
+
},
|
|
1237
|
+
keySize: 256 / 32
|
|
1238
|
+
});
|
|
1239
|
+
C.AES = BlockCipher._createHelper(AES);
|
|
1240
|
+
})();
|
|
1241
|
+
return CryptoJS.AES;
|
|
1242
|
+
});
|
|
1243
|
+
});
|
|
1244
|
+
|
|
1245
|
+
// /Users/chrisbreuer/Code/stacks/node_modules/bcryptjs/dist/bcrypt.js
|
|
1246
|
+
var require_bcrypt = __commonJS((exports, module) => {
|
|
1247
|
+
(function(global2, factory) {
|
|
1248
|
+
if (typeof define === "function" && define["amd"])
|
|
1249
|
+
define([], factory);
|
|
1250
|
+
else if (typeof require === "function" && typeof module === "object" && module && exports)
|
|
1251
|
+
module["exports"] = factory();
|
|
1252
|
+
else
|
|
1253
|
+
(global2["dcodeIO"] = global2["dcodeIO"] || {})["bcrypt"] = factory();
|
|
1254
|
+
})(exports, function() {
|
|
1255
|
+
var bcrypt = {};
|
|
1256
|
+
var randomFallback = null;
|
|
1257
|
+
function random(len) {
|
|
1258
|
+
if (typeof module !== "undefined" && module && module["exports"])
|
|
1259
|
+
try {
|
|
1260
|
+
return import.meta.require("crypto")["randomBytes"](len);
|
|
1261
|
+
} catch (e) {
|
|
1262
|
+
}
|
|
1263
|
+
try {
|
|
1264
|
+
var a;
|
|
1265
|
+
(self["crypto"] || self["msCrypto"])["getRandomValues"](a = new Uint32Array(len));
|
|
1266
|
+
return Array.prototype.slice.call(a);
|
|
1267
|
+
} catch (e) {
|
|
1268
|
+
}
|
|
1269
|
+
if (!randomFallback)
|
|
1270
|
+
throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");
|
|
1271
|
+
return randomFallback(len);
|
|
1272
|
+
}
|
|
1273
|
+
var randomAvailable = false;
|
|
1274
|
+
try {
|
|
1275
|
+
random(1);
|
|
1276
|
+
randomAvailable = true;
|
|
1277
|
+
} catch (e) {
|
|
1278
|
+
}
|
|
1279
|
+
randomFallback = null;
|
|
1280
|
+
bcrypt.setRandomFallback = function(random2) {
|
|
1281
|
+
randomFallback = random2;
|
|
1282
|
+
};
|
|
1283
|
+
bcrypt.genSaltSync = function(rounds, seed_length) {
|
|
1284
|
+
rounds = rounds || GENSALT_DEFAULT_LOG2_ROUNDS;
|
|
1285
|
+
if (typeof rounds !== "number")
|
|
1286
|
+
throw Error("Illegal arguments: " + typeof rounds + ", " + typeof seed_length);
|
|
1287
|
+
if (rounds < 4)
|
|
1288
|
+
rounds = 4;
|
|
1289
|
+
else if (rounds > 31)
|
|
1290
|
+
rounds = 31;
|
|
1291
|
+
var salt = [];
|
|
1292
|
+
salt.push("$2a$");
|
|
1293
|
+
if (rounds < 10)
|
|
1294
|
+
salt.push("0");
|
|
1295
|
+
salt.push(rounds.toString());
|
|
1296
|
+
salt.push("$");
|
|
1297
|
+
salt.push(base64_encode(random(BCRYPT_SALT_LEN), BCRYPT_SALT_LEN));
|
|
1298
|
+
return salt.join("");
|
|
1299
|
+
};
|
|
1300
|
+
bcrypt.genSalt = function(rounds, seed_length, callback) {
|
|
1301
|
+
if (typeof seed_length === "function")
|
|
1302
|
+
callback = seed_length, seed_length = undefined;
|
|
1303
|
+
if (typeof rounds === "function")
|
|
1304
|
+
callback = rounds, rounds = undefined;
|
|
1305
|
+
if (typeof rounds === "undefined")
|
|
1306
|
+
rounds = GENSALT_DEFAULT_LOG2_ROUNDS;
|
|
1307
|
+
else if (typeof rounds !== "number")
|
|
1308
|
+
throw Error("illegal arguments: " + typeof rounds);
|
|
1309
|
+
function _async(callback2) {
|
|
1310
|
+
nextTick(function() {
|
|
1311
|
+
try {
|
|
1312
|
+
callback2(null, bcrypt.genSaltSync(rounds));
|
|
1313
|
+
} catch (err) {
|
|
1314
|
+
callback2(err);
|
|
1315
|
+
}
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
if (callback) {
|
|
1319
|
+
if (typeof callback !== "function")
|
|
1320
|
+
throw Error("Illegal callback: " + typeof callback);
|
|
1321
|
+
_async(callback);
|
|
1322
|
+
} else
|
|
1323
|
+
return new Promise(function(resolve, reject) {
|
|
1324
|
+
_async(function(err, res) {
|
|
1325
|
+
if (err) {
|
|
1326
|
+
reject(err);
|
|
1327
|
+
return;
|
|
1328
|
+
}
|
|
1329
|
+
resolve(res);
|
|
1330
|
+
});
|
|
1331
|
+
});
|
|
1332
|
+
};
|
|
1333
|
+
bcrypt.hashSync = function(s, salt) {
|
|
1334
|
+
if (typeof salt === "undefined")
|
|
1335
|
+
salt = GENSALT_DEFAULT_LOG2_ROUNDS;
|
|
1336
|
+
if (typeof salt === "number")
|
|
1337
|
+
salt = bcrypt.genSaltSync(salt);
|
|
1338
|
+
if (typeof s !== "string" || typeof salt !== "string")
|
|
1339
|
+
throw Error("Illegal arguments: " + typeof s + ", " + typeof salt);
|
|
1340
|
+
return _hash(s, salt);
|
|
1341
|
+
};
|
|
1342
|
+
bcrypt.hash = function(s, salt, callback, progressCallback) {
|
|
1343
|
+
function _async(callback2) {
|
|
1344
|
+
if (typeof s === "string" && typeof salt === "number")
|
|
1345
|
+
bcrypt.genSalt(salt, function(err, salt2) {
|
|
1346
|
+
_hash(s, salt2, callback2, progressCallback);
|
|
1347
|
+
});
|
|
1348
|
+
else if (typeof s === "string" && typeof salt === "string")
|
|
1349
|
+
_hash(s, salt, callback2, progressCallback);
|
|
1350
|
+
else
|
|
1351
|
+
nextTick(callback2.bind(this, Error("Illegal arguments: " + typeof s + ", " + typeof salt)));
|
|
1352
|
+
}
|
|
1353
|
+
if (callback) {
|
|
1354
|
+
if (typeof callback !== "function")
|
|
1355
|
+
throw Error("Illegal callback: " + typeof callback);
|
|
1356
|
+
_async(callback);
|
|
1357
|
+
} else
|
|
1358
|
+
return new Promise(function(resolve, reject) {
|
|
1359
|
+
_async(function(err, res) {
|
|
1360
|
+
if (err) {
|
|
1361
|
+
reject(err);
|
|
1362
|
+
return;
|
|
1363
|
+
}
|
|
1364
|
+
resolve(res);
|
|
1365
|
+
});
|
|
1366
|
+
});
|
|
1367
|
+
};
|
|
1368
|
+
function safeStringCompare(known, unknown) {
|
|
1369
|
+
var right = 0, wrong = 0;
|
|
1370
|
+
for (var i = 0, k = known.length;i < k; ++i) {
|
|
1371
|
+
if (known.charCodeAt(i) === unknown.charCodeAt(i))
|
|
1372
|
+
++right;
|
|
1373
|
+
else
|
|
1374
|
+
++wrong;
|
|
1375
|
+
}
|
|
1376
|
+
if (right < 0)
|
|
1377
|
+
return false;
|
|
1378
|
+
return wrong === 0;
|
|
1379
|
+
}
|
|
1380
|
+
bcrypt.compareSync = function(s, hash) {
|
|
1381
|
+
if (typeof s !== "string" || typeof hash !== "string")
|
|
1382
|
+
throw Error("Illegal arguments: " + typeof s + ", " + typeof hash);
|
|
1383
|
+
if (hash.length !== 60)
|
|
1384
|
+
return false;
|
|
1385
|
+
return safeStringCompare(bcrypt.hashSync(s, hash.substr(0, hash.length - 31)), hash);
|
|
1386
|
+
};
|
|
1387
|
+
bcrypt.compare = function(s, hash, callback, progressCallback) {
|
|
1388
|
+
function _async(callback2) {
|
|
1389
|
+
if (typeof s !== "string" || typeof hash !== "string") {
|
|
1390
|
+
nextTick(callback2.bind(this, Error("Illegal arguments: " + typeof s + ", " + typeof hash)));
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
if (hash.length !== 60) {
|
|
1394
|
+
nextTick(callback2.bind(this, null, false));
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1397
|
+
bcrypt.hash(s, hash.substr(0, 29), function(err, comp) {
|
|
1398
|
+
if (err)
|
|
1399
|
+
callback2(err);
|
|
1400
|
+
else
|
|
1401
|
+
callback2(null, safeStringCompare(comp, hash));
|
|
1402
|
+
}, progressCallback);
|
|
1403
|
+
}
|
|
1404
|
+
if (callback) {
|
|
1405
|
+
if (typeof callback !== "function")
|
|
1406
|
+
throw Error("Illegal callback: " + typeof callback);
|
|
1407
|
+
_async(callback);
|
|
1408
|
+
} else
|
|
1409
|
+
return new Promise(function(resolve, reject) {
|
|
1410
|
+
_async(function(err, res) {
|
|
1411
|
+
if (err) {
|
|
1412
|
+
reject(err);
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
resolve(res);
|
|
1416
|
+
});
|
|
1417
|
+
});
|
|
1418
|
+
};
|
|
1419
|
+
bcrypt.getRounds = function(hash) {
|
|
1420
|
+
if (typeof hash !== "string")
|
|
1421
|
+
throw Error("Illegal arguments: " + typeof hash);
|
|
1422
|
+
return parseInt(hash.split("$")[2], 10);
|
|
1423
|
+
};
|
|
1424
|
+
bcrypt.getSalt = function(hash) {
|
|
1425
|
+
if (typeof hash !== "string")
|
|
1426
|
+
throw Error("Illegal arguments: " + typeof hash);
|
|
1427
|
+
if (hash.length !== 60)
|
|
1428
|
+
throw Error("Illegal hash length: " + hash.length + " != 60");
|
|
1429
|
+
return hash.substring(0, 29);
|
|
1430
|
+
};
|
|
1431
|
+
var nextTick = typeof process !== "undefined" && process && typeof process.nextTick === "function" ? typeof setImmediate === "function" ? setImmediate : process.nextTick : setTimeout;
|
|
1432
|
+
function stringToBytes(str) {
|
|
1433
|
+
var out = [], i = 0;
|
|
1434
|
+
utfx.encodeUTF16toUTF8(function() {
|
|
1435
|
+
if (i >= str.length)
|
|
1436
|
+
return null;
|
|
1437
|
+
return str.charCodeAt(i++);
|
|
1438
|
+
}, function(b) {
|
|
1439
|
+
out.push(b);
|
|
1440
|
+
});
|
|
1441
|
+
return out;
|
|
1442
|
+
}
|
|
1443
|
+
var BASE64_CODE = "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split("");
|
|
1444
|
+
var BASE64_INDEX = [
|
|
1445
|
+
-1,
|
|
1446
|
+
-1,
|
|
1447
|
+
-1,
|
|
1448
|
+
-1,
|
|
1449
|
+
-1,
|
|
1450
|
+
-1,
|
|
1451
|
+
-1,
|
|
1452
|
+
-1,
|
|
1453
|
+
-1,
|
|
1454
|
+
-1,
|
|
1455
|
+
-1,
|
|
1456
|
+
-1,
|
|
1457
|
+
-1,
|
|
1458
|
+
-1,
|
|
1459
|
+
-1,
|
|
1460
|
+
-1,
|
|
1461
|
+
-1,
|
|
1462
|
+
-1,
|
|
1463
|
+
-1,
|
|
1464
|
+
-1,
|
|
1465
|
+
-1,
|
|
1466
|
+
-1,
|
|
1467
|
+
-1,
|
|
1468
|
+
-1,
|
|
1469
|
+
-1,
|
|
1470
|
+
-1,
|
|
1471
|
+
-1,
|
|
1472
|
+
-1,
|
|
1473
|
+
-1,
|
|
1474
|
+
-1,
|
|
1475
|
+
-1,
|
|
1476
|
+
-1,
|
|
1477
|
+
-1,
|
|
1478
|
+
-1,
|
|
1479
|
+
-1,
|
|
1480
|
+
-1,
|
|
1481
|
+
-1,
|
|
1482
|
+
-1,
|
|
1483
|
+
-1,
|
|
1484
|
+
-1,
|
|
1485
|
+
-1,
|
|
1486
|
+
-1,
|
|
1487
|
+
-1,
|
|
1488
|
+
-1,
|
|
1489
|
+
-1,
|
|
1490
|
+
-1,
|
|
1491
|
+
0,
|
|
1492
|
+
1,
|
|
1493
|
+
54,
|
|
1494
|
+
55,
|
|
1495
|
+
56,
|
|
1496
|
+
57,
|
|
1497
|
+
58,
|
|
1498
|
+
59,
|
|
1499
|
+
60,
|
|
1500
|
+
61,
|
|
1501
|
+
62,
|
|
1502
|
+
63,
|
|
1503
|
+
-1,
|
|
1504
|
+
-1,
|
|
1505
|
+
-1,
|
|
1506
|
+
-1,
|
|
1507
|
+
-1,
|
|
1508
|
+
-1,
|
|
1509
|
+
-1,
|
|
1510
|
+
2,
|
|
1511
|
+
3,
|
|
1512
|
+
4,
|
|
1513
|
+
5,
|
|
1514
|
+
6,
|
|
1515
|
+
7,
|
|
1516
|
+
8,
|
|
1517
|
+
9,
|
|
1518
|
+
10,
|
|
1519
|
+
11,
|
|
1520
|
+
12,
|
|
1521
|
+
13,
|
|
1522
|
+
14,
|
|
1523
|
+
15,
|
|
1524
|
+
16,
|
|
1525
|
+
17,
|
|
1526
|
+
18,
|
|
1527
|
+
19,
|
|
1528
|
+
20,
|
|
1529
|
+
21,
|
|
1530
|
+
22,
|
|
1531
|
+
23,
|
|
1532
|
+
24,
|
|
1533
|
+
25,
|
|
1534
|
+
26,
|
|
1535
|
+
27,
|
|
1536
|
+
-1,
|
|
1537
|
+
-1,
|
|
1538
|
+
-1,
|
|
1539
|
+
-1,
|
|
1540
|
+
-1,
|
|
1541
|
+
-1,
|
|
1542
|
+
28,
|
|
1543
|
+
29,
|
|
1544
|
+
30,
|
|
1545
|
+
31,
|
|
1546
|
+
32,
|
|
1547
|
+
33,
|
|
1548
|
+
34,
|
|
1549
|
+
35,
|
|
1550
|
+
36,
|
|
1551
|
+
37,
|
|
1552
|
+
38,
|
|
1553
|
+
39,
|
|
1554
|
+
40,
|
|
1555
|
+
41,
|
|
1556
|
+
42,
|
|
1557
|
+
43,
|
|
1558
|
+
44,
|
|
1559
|
+
45,
|
|
1560
|
+
46,
|
|
1561
|
+
47,
|
|
1562
|
+
48,
|
|
1563
|
+
49,
|
|
1564
|
+
50,
|
|
1565
|
+
51,
|
|
1566
|
+
52,
|
|
1567
|
+
53,
|
|
1568
|
+
-1,
|
|
1569
|
+
-1,
|
|
1570
|
+
-1,
|
|
1571
|
+
-1,
|
|
1572
|
+
-1
|
|
1573
|
+
];
|
|
1574
|
+
var stringFromCharCode = String.fromCharCode;
|
|
1575
|
+
function base64_encode(b, len) {
|
|
1576
|
+
var off = 0, rs = [], c1, c2;
|
|
1577
|
+
if (len <= 0 || len > b.length)
|
|
1578
|
+
throw Error("Illegal len: " + len);
|
|
1579
|
+
while (off < len) {
|
|
1580
|
+
c1 = b[off++] & 255;
|
|
1581
|
+
rs.push(BASE64_CODE[c1 >> 2 & 63]);
|
|
1582
|
+
c1 = (c1 & 3) << 4;
|
|
1583
|
+
if (off >= len) {
|
|
1584
|
+
rs.push(BASE64_CODE[c1 & 63]);
|
|
1585
|
+
break;
|
|
1586
|
+
}
|
|
1587
|
+
c2 = b[off++] & 255;
|
|
1588
|
+
c1 |= c2 >> 4 & 15;
|
|
1589
|
+
rs.push(BASE64_CODE[c1 & 63]);
|
|
1590
|
+
c1 = (c2 & 15) << 2;
|
|
1591
|
+
if (off >= len) {
|
|
1592
|
+
rs.push(BASE64_CODE[c1 & 63]);
|
|
1593
|
+
break;
|
|
1594
|
+
}
|
|
1595
|
+
c2 = b[off++] & 255;
|
|
1596
|
+
c1 |= c2 >> 6 & 3;
|
|
1597
|
+
rs.push(BASE64_CODE[c1 & 63]);
|
|
1598
|
+
rs.push(BASE64_CODE[c2 & 63]);
|
|
1599
|
+
}
|
|
1600
|
+
return rs.join("");
|
|
1601
|
+
}
|
|
1602
|
+
function base64_decode(s, len) {
|
|
1603
|
+
var off = 0, slen = s.length, olen = 0, rs = [], c1, c2, c3, c4, o, code;
|
|
1604
|
+
if (len <= 0)
|
|
1605
|
+
throw Error("Illegal len: " + len);
|
|
1606
|
+
while (off < slen - 1 && olen < len) {
|
|
1607
|
+
code = s.charCodeAt(off++);
|
|
1608
|
+
c1 = code < BASE64_INDEX.length ? BASE64_INDEX[code] : -1;
|
|
1609
|
+
code = s.charCodeAt(off++);
|
|
1610
|
+
c2 = code < BASE64_INDEX.length ? BASE64_INDEX[code] : -1;
|
|
1611
|
+
if (c1 == -1 || c2 == -1)
|
|
1612
|
+
break;
|
|
1613
|
+
o = c1 << 2 >>> 0;
|
|
1614
|
+
o |= (c2 & 48) >> 4;
|
|
1615
|
+
rs.push(stringFromCharCode(o));
|
|
1616
|
+
if (++olen >= len || off >= slen)
|
|
1617
|
+
break;
|
|
1618
|
+
code = s.charCodeAt(off++);
|
|
1619
|
+
c3 = code < BASE64_INDEX.length ? BASE64_INDEX[code] : -1;
|
|
1620
|
+
if (c3 == -1)
|
|
1621
|
+
break;
|
|
1622
|
+
o = (c2 & 15) << 4 >>> 0;
|
|
1623
|
+
o |= (c3 & 60) >> 2;
|
|
1624
|
+
rs.push(stringFromCharCode(o));
|
|
1625
|
+
if (++olen >= len || off >= slen)
|
|
1626
|
+
break;
|
|
1627
|
+
code = s.charCodeAt(off++);
|
|
1628
|
+
c4 = code < BASE64_INDEX.length ? BASE64_INDEX[code] : -1;
|
|
1629
|
+
o = (c3 & 3) << 6 >>> 0;
|
|
1630
|
+
o |= c4;
|
|
1631
|
+
rs.push(stringFromCharCode(o));
|
|
1632
|
+
++olen;
|
|
1633
|
+
}
|
|
1634
|
+
var res = [];
|
|
1635
|
+
for (off = 0;off < olen; off++)
|
|
1636
|
+
res.push(rs[off].charCodeAt(0));
|
|
1637
|
+
return res;
|
|
1638
|
+
}
|
|
1639
|
+
var utfx = function() {
|
|
1640
|
+
var utfx2 = {};
|
|
1641
|
+
utfx2.MAX_CODEPOINT = 1114111;
|
|
1642
|
+
utfx2.encodeUTF8 = function(src, dst) {
|
|
1643
|
+
var cp = null;
|
|
1644
|
+
if (typeof src === "number")
|
|
1645
|
+
cp = src, src = function() {
|
|
1646
|
+
return null;
|
|
1647
|
+
};
|
|
1648
|
+
while (cp !== null || (cp = src()) !== null) {
|
|
1649
|
+
if (cp < 128)
|
|
1650
|
+
dst(cp & 127);
|
|
1651
|
+
else if (cp < 2048)
|
|
1652
|
+
dst(cp >> 6 & 31 | 192), dst(cp & 63 | 128);
|
|
1653
|
+
else if (cp < 65536)
|
|
1654
|
+
dst(cp >> 12 & 15 | 224), dst(cp >> 6 & 63 | 128), dst(cp & 63 | 128);
|
|
1655
|
+
else
|
|
1656
|
+
dst(cp >> 18 & 7 | 240), dst(cp >> 12 & 63 | 128), dst(cp >> 6 & 63 | 128), dst(cp & 63 | 128);
|
|
1657
|
+
cp = null;
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1660
|
+
utfx2.decodeUTF8 = function(src, dst) {
|
|
1661
|
+
var a, b, c, d, fail = function(b2) {
|
|
1662
|
+
b2 = b2.slice(0, b2.indexOf(null));
|
|
1663
|
+
var err = Error(b2.toString());
|
|
1664
|
+
err.name = "TruncatedError";
|
|
1665
|
+
err["bytes"] = b2;
|
|
1666
|
+
throw err;
|
|
1667
|
+
};
|
|
1668
|
+
while ((a = src()) !== null) {
|
|
1669
|
+
if ((a & 128) === 0)
|
|
1670
|
+
dst(a);
|
|
1671
|
+
else if ((a & 224) === 192)
|
|
1672
|
+
(b = src()) === null && fail([a, b]), dst((a & 31) << 6 | b & 63);
|
|
1673
|
+
else if ((a & 240) === 224)
|
|
1674
|
+
((b = src()) === null || (c = src()) === null) && fail([a, b, c]), dst((a & 15) << 12 | (b & 63) << 6 | c & 63);
|
|
1675
|
+
else if ((a & 248) === 240)
|
|
1676
|
+
((b = src()) === null || (c = src()) === null || (d = src()) === null) && fail([a, b, c, d]), dst((a & 7) << 18 | (b & 63) << 12 | (c & 63) << 6 | d & 63);
|
|
1677
|
+
else
|
|
1678
|
+
throw RangeError("Illegal starting byte: " + a);
|
|
1679
|
+
}
|
|
1680
|
+
};
|
|
1681
|
+
utfx2.UTF16toUTF8 = function(src, dst) {
|
|
1682
|
+
var c1, c2 = null;
|
|
1683
|
+
while (true) {
|
|
1684
|
+
if ((c1 = c2 !== null ? c2 : src()) === null)
|
|
1685
|
+
break;
|
|
1686
|
+
if (c1 >= 55296 && c1 <= 57343) {
|
|
1687
|
+
if ((c2 = src()) !== null) {
|
|
1688
|
+
if (c2 >= 56320 && c2 <= 57343) {
|
|
1689
|
+
dst((c1 - 55296) * 1024 + c2 - 56320 + 65536);
|
|
1690
|
+
c2 = null;
|
|
1691
|
+
continue;
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
dst(c1);
|
|
1696
|
+
}
|
|
1697
|
+
if (c2 !== null)
|
|
1698
|
+
dst(c2);
|
|
1699
|
+
};
|
|
1700
|
+
utfx2.UTF8toUTF16 = function(src, dst) {
|
|
1701
|
+
var cp = null;
|
|
1702
|
+
if (typeof src === "number")
|
|
1703
|
+
cp = src, src = function() {
|
|
1704
|
+
return null;
|
|
1705
|
+
};
|
|
1706
|
+
while (cp !== null || (cp = src()) !== null) {
|
|
1707
|
+
if (cp <= 65535)
|
|
1708
|
+
dst(cp);
|
|
1709
|
+
else
|
|
1710
|
+
cp -= 65536, dst((cp >> 10) + 55296), dst(cp % 1024 + 56320);
|
|
1711
|
+
cp = null;
|
|
1712
|
+
}
|
|
1713
|
+
};
|
|
1714
|
+
utfx2.encodeUTF16toUTF8 = function(src, dst) {
|
|
1715
|
+
utfx2.UTF16toUTF8(src, function(cp) {
|
|
1716
|
+
utfx2.encodeUTF8(cp, dst);
|
|
1717
|
+
});
|
|
1718
|
+
};
|
|
1719
|
+
utfx2.decodeUTF8toUTF16 = function(src, dst) {
|
|
1720
|
+
utfx2.decodeUTF8(src, function(cp) {
|
|
1721
|
+
utfx2.UTF8toUTF16(cp, dst);
|
|
1722
|
+
});
|
|
1723
|
+
};
|
|
1724
|
+
utfx2.calculateCodePoint = function(cp) {
|
|
1725
|
+
return cp < 128 ? 1 : cp < 2048 ? 2 : cp < 65536 ? 3 : 4;
|
|
1726
|
+
};
|
|
1727
|
+
utfx2.calculateUTF8 = function(src) {
|
|
1728
|
+
var cp, l = 0;
|
|
1729
|
+
while ((cp = src()) !== null)
|
|
1730
|
+
l += utfx2.calculateCodePoint(cp);
|
|
1731
|
+
return l;
|
|
1732
|
+
};
|
|
1733
|
+
utfx2.calculateUTF16asUTF8 = function(src) {
|
|
1734
|
+
var n = 0, l = 0;
|
|
1735
|
+
utfx2.UTF16toUTF8(src, function(cp) {
|
|
1736
|
+
++n;
|
|
1737
|
+
l += utfx2.calculateCodePoint(cp);
|
|
1738
|
+
});
|
|
1739
|
+
return [n, l];
|
|
1740
|
+
};
|
|
1741
|
+
return utfx2;
|
|
1742
|
+
}();
|
|
1743
|
+
Date.now = Date.now || function() {
|
|
1744
|
+
return +new Date;
|
|
1745
|
+
};
|
|
1746
|
+
var BCRYPT_SALT_LEN = 16;
|
|
1747
|
+
var GENSALT_DEFAULT_LOG2_ROUNDS = 10;
|
|
1748
|
+
var BLOWFISH_NUM_ROUNDS = 16;
|
|
1749
|
+
var MAX_EXECUTION_TIME = 100;
|
|
1750
|
+
var P_ORIG = [
|
|
1751
|
+
608135816,
|
|
1752
|
+
2242054355,
|
|
1753
|
+
320440878,
|
|
1754
|
+
57701188,
|
|
1755
|
+
2752067618,
|
|
1756
|
+
698298832,
|
|
1757
|
+
137296536,
|
|
1758
|
+
3964562569,
|
|
1759
|
+
1160258022,
|
|
1760
|
+
953160567,
|
|
1761
|
+
3193202383,
|
|
1762
|
+
887688300,
|
|
1763
|
+
3232508343,
|
|
1764
|
+
3380367581,
|
|
1765
|
+
1065670069,
|
|
1766
|
+
3041331479,
|
|
1767
|
+
2450970073,
|
|
1768
|
+
2306472731
|
|
1769
|
+
];
|
|
1770
|
+
var S_ORIG = [
|
|
1771
|
+
3509652390,
|
|
1772
|
+
2564797868,
|
|
1773
|
+
805139163,
|
|
1774
|
+
3491422135,
|
|
1775
|
+
3101798381,
|
|
1776
|
+
1780907670,
|
|
1777
|
+
3128725573,
|
|
1778
|
+
4046225305,
|
|
1779
|
+
614570311,
|
|
1780
|
+
3012652279,
|
|
1781
|
+
134345442,
|
|
1782
|
+
2240740374,
|
|
1783
|
+
1667834072,
|
|
1784
|
+
1901547113,
|
|
1785
|
+
2757295779,
|
|
1786
|
+
4103290238,
|
|
1787
|
+
227898511,
|
|
1788
|
+
1921955416,
|
|
1789
|
+
1904987480,
|
|
1790
|
+
2182433518,
|
|
1791
|
+
2069144605,
|
|
1792
|
+
3260701109,
|
|
1793
|
+
2620446009,
|
|
1794
|
+
720527379,
|
|
1795
|
+
3318853667,
|
|
1796
|
+
677414384,
|
|
1797
|
+
3393288472,
|
|
1798
|
+
3101374703,
|
|
1799
|
+
2390351024,
|
|
1800
|
+
1614419982,
|
|
1801
|
+
1822297739,
|
|
1802
|
+
2954791486,
|
|
1803
|
+
3608508353,
|
|
1804
|
+
3174124327,
|
|
1805
|
+
2024746970,
|
|
1806
|
+
1432378464,
|
|
1807
|
+
3864339955,
|
|
1808
|
+
2857741204,
|
|
1809
|
+
1464375394,
|
|
1810
|
+
1676153920,
|
|
1811
|
+
1439316330,
|
|
1812
|
+
715854006,
|
|
1813
|
+
3033291828,
|
|
1814
|
+
289532110,
|
|
1815
|
+
2706671279,
|
|
1816
|
+
2087905683,
|
|
1817
|
+
3018724369,
|
|
1818
|
+
1668267050,
|
|
1819
|
+
732546397,
|
|
1820
|
+
1947742710,
|
|
1821
|
+
3462151702,
|
|
1822
|
+
2609353502,
|
|
1823
|
+
2950085171,
|
|
1824
|
+
1814351708,
|
|
1825
|
+
2050118529,
|
|
1826
|
+
680887927,
|
|
1827
|
+
999245976,
|
|
1828
|
+
1800124847,
|
|
1829
|
+
3300911131,
|
|
1830
|
+
1713906067,
|
|
1831
|
+
1641548236,
|
|
1832
|
+
4213287313,
|
|
1833
|
+
1216130144,
|
|
1834
|
+
1575780402,
|
|
1835
|
+
4018429277,
|
|
1836
|
+
3917837745,
|
|
1837
|
+
3693486850,
|
|
1838
|
+
3949271944,
|
|
1839
|
+
596196993,
|
|
1840
|
+
3549867205,
|
|
1841
|
+
258830323,
|
|
1842
|
+
2213823033,
|
|
1843
|
+
772490370,
|
|
1844
|
+
2760122372,
|
|
1845
|
+
1774776394,
|
|
1846
|
+
2652871518,
|
|
1847
|
+
566650946,
|
|
1848
|
+
4142492826,
|
|
1849
|
+
1728879713,
|
|
1850
|
+
2882767088,
|
|
1851
|
+
1783734482,
|
|
1852
|
+
3629395816,
|
|
1853
|
+
2517608232,
|
|
1854
|
+
2874225571,
|
|
1855
|
+
1861159788,
|
|
1856
|
+
326777828,
|
|
1857
|
+
3124490320,
|
|
1858
|
+
2130389656,
|
|
1859
|
+
2716951837,
|
|
1860
|
+
967770486,
|
|
1861
|
+
1724537150,
|
|
1862
|
+
2185432712,
|
|
1863
|
+
2364442137,
|
|
1864
|
+
1164943284,
|
|
1865
|
+
2105845187,
|
|
1866
|
+
998989502,
|
|
1867
|
+
3765401048,
|
|
1868
|
+
2244026483,
|
|
1869
|
+
1075463327,
|
|
1870
|
+
1455516326,
|
|
1871
|
+
1322494562,
|
|
1872
|
+
910128902,
|
|
1873
|
+
469688178,
|
|
1874
|
+
1117454909,
|
|
1875
|
+
936433444,
|
|
1876
|
+
3490320968,
|
|
1877
|
+
3675253459,
|
|
1878
|
+
1240580251,
|
|
1879
|
+
122909385,
|
|
1880
|
+
2157517691,
|
|
1881
|
+
634681816,
|
|
1882
|
+
4142456567,
|
|
1883
|
+
3825094682,
|
|
1884
|
+
3061402683,
|
|
1885
|
+
2540495037,
|
|
1886
|
+
79693498,
|
|
1887
|
+
3249098678,
|
|
1888
|
+
1084186820,
|
|
1889
|
+
1583128258,
|
|
1890
|
+
426386531,
|
|
1891
|
+
1761308591,
|
|
1892
|
+
1047286709,
|
|
1893
|
+
322548459,
|
|
1894
|
+
995290223,
|
|
1895
|
+
1845252383,
|
|
1896
|
+
2603652396,
|
|
1897
|
+
3431023940,
|
|
1898
|
+
2942221577,
|
|
1899
|
+
3202600964,
|
|
1900
|
+
3727903485,
|
|
1901
|
+
1712269319,
|
|
1902
|
+
422464435,
|
|
1903
|
+
3234572375,
|
|
1904
|
+
1170764815,
|
|
1905
|
+
3523960633,
|
|
1906
|
+
3117677531,
|
|
1907
|
+
1434042557,
|
|
1908
|
+
442511882,
|
|
1909
|
+
3600875718,
|
|
1910
|
+
1076654713,
|
|
1911
|
+
1738483198,
|
|
1912
|
+
4213154764,
|
|
1913
|
+
2393238008,
|
|
1914
|
+
3677496056,
|
|
1915
|
+
1014306527,
|
|
1916
|
+
4251020053,
|
|
1917
|
+
793779912,
|
|
1918
|
+
2902807211,
|
|
1919
|
+
842905082,
|
|
1920
|
+
4246964064,
|
|
1921
|
+
1395751752,
|
|
1922
|
+
1040244610,
|
|
1923
|
+
2656851899,
|
|
1924
|
+
3396308128,
|
|
1925
|
+
445077038,
|
|
1926
|
+
3742853595,
|
|
1927
|
+
3577915638,
|
|
1928
|
+
679411651,
|
|
1929
|
+
2892444358,
|
|
1930
|
+
2354009459,
|
|
1931
|
+
1767581616,
|
|
1932
|
+
3150600392,
|
|
1933
|
+
3791627101,
|
|
1934
|
+
3102740896,
|
|
1935
|
+
284835224,
|
|
1936
|
+
4246832056,
|
|
1937
|
+
1258075500,
|
|
1938
|
+
768725851,
|
|
1939
|
+
2589189241,
|
|
1940
|
+
3069724005,
|
|
1941
|
+
3532540348,
|
|
1942
|
+
1274779536,
|
|
1943
|
+
3789419226,
|
|
1944
|
+
2764799539,
|
|
1945
|
+
1660621633,
|
|
1946
|
+
3471099624,
|
|
1947
|
+
4011903706,
|
|
1948
|
+
913787905,
|
|
1949
|
+
3497959166,
|
|
1950
|
+
737222580,
|
|
1951
|
+
2514213453,
|
|
1952
|
+
2928710040,
|
|
1953
|
+
3937242737,
|
|
1954
|
+
1804850592,
|
|
1955
|
+
3499020752,
|
|
1956
|
+
2949064160,
|
|
1957
|
+
2386320175,
|
|
1958
|
+
2390070455,
|
|
1959
|
+
2415321851,
|
|
1960
|
+
4061277028,
|
|
1961
|
+
2290661394,
|
|
1962
|
+
2416832540,
|
|
1963
|
+
1336762016,
|
|
1964
|
+
1754252060,
|
|
1965
|
+
3520065937,
|
|
1966
|
+
3014181293,
|
|
1967
|
+
791618072,
|
|
1968
|
+
3188594551,
|
|
1969
|
+
3933548030,
|
|
1970
|
+
2332172193,
|
|
1971
|
+
3852520463,
|
|
1972
|
+
3043980520,
|
|
1973
|
+
413987798,
|
|
1974
|
+
3465142937,
|
|
1975
|
+
3030929376,
|
|
1976
|
+
4245938359,
|
|
1977
|
+
2093235073,
|
|
1978
|
+
3534596313,
|
|
1979
|
+
375366246,
|
|
1980
|
+
2157278981,
|
|
1981
|
+
2479649556,
|
|
1982
|
+
555357303,
|
|
1983
|
+
3870105701,
|
|
1984
|
+
2008414854,
|
|
1985
|
+
3344188149,
|
|
1986
|
+
4221384143,
|
|
1987
|
+
3956125452,
|
|
1988
|
+
2067696032,
|
|
1989
|
+
3594591187,
|
|
1990
|
+
2921233993,
|
|
1991
|
+
2428461,
|
|
1992
|
+
544322398,
|
|
1993
|
+
577241275,
|
|
1994
|
+
1471733935,
|
|
1995
|
+
610547355,
|
|
1996
|
+
4027169054,
|
|
1997
|
+
1432588573,
|
|
1998
|
+
1507829418,
|
|
1999
|
+
2025931657,
|
|
2000
|
+
3646575487,
|
|
2001
|
+
545086370,
|
|
2002
|
+
48609733,
|
|
2003
|
+
2200306550,
|
|
2004
|
+
1653985193,
|
|
2005
|
+
298326376,
|
|
2006
|
+
1316178497,
|
|
2007
|
+
3007786442,
|
|
2008
|
+
2064951626,
|
|
2009
|
+
458293330,
|
|
2010
|
+
2589141269,
|
|
2011
|
+
3591329599,
|
|
2012
|
+
3164325604,
|
|
2013
|
+
727753846,
|
|
2014
|
+
2179363840,
|
|
2015
|
+
146436021,
|
|
2016
|
+
1461446943,
|
|
2017
|
+
4069977195,
|
|
2018
|
+
705550613,
|
|
2019
|
+
3059967265,
|
|
2020
|
+
3887724982,
|
|
2021
|
+
4281599278,
|
|
2022
|
+
3313849956,
|
|
2023
|
+
1404054877,
|
|
2024
|
+
2845806497,
|
|
2025
|
+
146425753,
|
|
2026
|
+
1854211946,
|
|
2027
|
+
1266315497,
|
|
2028
|
+
3048417604,
|
|
2029
|
+
3681880366,
|
|
2030
|
+
3289982499,
|
|
2031
|
+
2909710000,
|
|
2032
|
+
1235738493,
|
|
2033
|
+
2632868024,
|
|
2034
|
+
2414719590,
|
|
2035
|
+
3970600049,
|
|
2036
|
+
1771706367,
|
|
2037
|
+
1449415276,
|
|
2038
|
+
3266420449,
|
|
2039
|
+
422970021,
|
|
2040
|
+
1963543593,
|
|
2041
|
+
2690192192,
|
|
2042
|
+
3826793022,
|
|
2043
|
+
1062508698,
|
|
2044
|
+
1531092325,
|
|
2045
|
+
1804592342,
|
|
2046
|
+
2583117782,
|
|
2047
|
+
2714934279,
|
|
2048
|
+
4024971509,
|
|
2049
|
+
1294809318,
|
|
2050
|
+
4028980673,
|
|
2051
|
+
1289560198,
|
|
2052
|
+
2221992742,
|
|
2053
|
+
1669523910,
|
|
2054
|
+
35572830,
|
|
2055
|
+
157838143,
|
|
2056
|
+
1052438473,
|
|
2057
|
+
1016535060,
|
|
2058
|
+
1802137761,
|
|
2059
|
+
1753167236,
|
|
2060
|
+
1386275462,
|
|
2061
|
+
3080475397,
|
|
2062
|
+
2857371447,
|
|
2063
|
+
1040679964,
|
|
2064
|
+
2145300060,
|
|
2065
|
+
2390574316,
|
|
2066
|
+
1461121720,
|
|
2067
|
+
2956646967,
|
|
2068
|
+
4031777805,
|
|
2069
|
+
4028374788,
|
|
2070
|
+
33600511,
|
|
2071
|
+
2920084762,
|
|
2072
|
+
1018524850,
|
|
2073
|
+
629373528,
|
|
2074
|
+
3691585981,
|
|
2075
|
+
3515945977,
|
|
2076
|
+
2091462646,
|
|
2077
|
+
2486323059,
|
|
2078
|
+
586499841,
|
|
2079
|
+
988145025,
|
|
2080
|
+
935516892,
|
|
2081
|
+
3367335476,
|
|
2082
|
+
2599673255,
|
|
2083
|
+
2839830854,
|
|
2084
|
+
265290510,
|
|
2085
|
+
3972581182,
|
|
2086
|
+
2759138881,
|
|
2087
|
+
3795373465,
|
|
2088
|
+
1005194799,
|
|
2089
|
+
847297441,
|
|
2090
|
+
406762289,
|
|
2091
|
+
1314163512,
|
|
2092
|
+
1332590856,
|
|
2093
|
+
1866599683,
|
|
2094
|
+
4127851711,
|
|
2095
|
+
750260880,
|
|
2096
|
+
613907577,
|
|
2097
|
+
1450815602,
|
|
2098
|
+
3165620655,
|
|
2099
|
+
3734664991,
|
|
2100
|
+
3650291728,
|
|
2101
|
+
3012275730,
|
|
2102
|
+
3704569646,
|
|
2103
|
+
1427272223,
|
|
2104
|
+
778793252,
|
|
2105
|
+
1343938022,
|
|
2106
|
+
2676280711,
|
|
2107
|
+
2052605720,
|
|
2108
|
+
1946737175,
|
|
2109
|
+
3164576444,
|
|
2110
|
+
3914038668,
|
|
2111
|
+
3967478842,
|
|
2112
|
+
3682934266,
|
|
2113
|
+
1661551462,
|
|
2114
|
+
3294938066,
|
|
2115
|
+
4011595847,
|
|
2116
|
+
840292616,
|
|
2117
|
+
3712170807,
|
|
2118
|
+
616741398,
|
|
2119
|
+
312560963,
|
|
2120
|
+
711312465,
|
|
2121
|
+
1351876610,
|
|
2122
|
+
322626781,
|
|
2123
|
+
1910503582,
|
|
2124
|
+
271666773,
|
|
2125
|
+
2175563734,
|
|
2126
|
+
1594956187,
|
|
2127
|
+
70604529,
|
|
2128
|
+
3617834859,
|
|
2129
|
+
1007753275,
|
|
2130
|
+
1495573769,
|
|
2131
|
+
4069517037,
|
|
2132
|
+
2549218298,
|
|
2133
|
+
2663038764,
|
|
2134
|
+
504708206,
|
|
2135
|
+
2263041392,
|
|
2136
|
+
3941167025,
|
|
2137
|
+
2249088522,
|
|
2138
|
+
1514023603,
|
|
2139
|
+
1998579484,
|
|
2140
|
+
1312622330,
|
|
2141
|
+
694541497,
|
|
2142
|
+
2582060303,
|
|
2143
|
+
2151582166,
|
|
2144
|
+
1382467621,
|
|
2145
|
+
776784248,
|
|
2146
|
+
2618340202,
|
|
2147
|
+
3323268794,
|
|
2148
|
+
2497899128,
|
|
2149
|
+
2784771155,
|
|
2150
|
+
503983604,
|
|
2151
|
+
4076293799,
|
|
2152
|
+
907881277,
|
|
2153
|
+
423175695,
|
|
2154
|
+
432175456,
|
|
2155
|
+
1378068232,
|
|
2156
|
+
4145222326,
|
|
2157
|
+
3954048622,
|
|
2158
|
+
3938656102,
|
|
2159
|
+
3820766613,
|
|
2160
|
+
2793130115,
|
|
2161
|
+
2977904593,
|
|
2162
|
+
26017576,
|
|
2163
|
+
3274890735,
|
|
2164
|
+
3194772133,
|
|
2165
|
+
1700274565,
|
|
2166
|
+
1756076034,
|
|
2167
|
+
4006520079,
|
|
2168
|
+
3677328699,
|
|
2169
|
+
720338349,
|
|
2170
|
+
1533947780,
|
|
2171
|
+
354530856,
|
|
2172
|
+
688349552,
|
|
2173
|
+
3973924725,
|
|
2174
|
+
1637815568,
|
|
2175
|
+
332179504,
|
|
2176
|
+
3949051286,
|
|
2177
|
+
53804574,
|
|
2178
|
+
2852348879,
|
|
2179
|
+
3044236432,
|
|
2180
|
+
1282449977,
|
|
2181
|
+
3583942155,
|
|
2182
|
+
3416972820,
|
|
2183
|
+
4006381244,
|
|
2184
|
+
1617046695,
|
|
2185
|
+
2628476075,
|
|
2186
|
+
3002303598,
|
|
2187
|
+
1686838959,
|
|
2188
|
+
431878346,
|
|
2189
|
+
2686675385,
|
|
2190
|
+
1700445008,
|
|
2191
|
+
1080580658,
|
|
2192
|
+
1009431731,
|
|
2193
|
+
832498133,
|
|
2194
|
+
3223435511,
|
|
2195
|
+
2605976345,
|
|
2196
|
+
2271191193,
|
|
2197
|
+
2516031870,
|
|
2198
|
+
1648197032,
|
|
2199
|
+
4164389018,
|
|
2200
|
+
2548247927,
|
|
2201
|
+
300782431,
|
|
2202
|
+
375919233,
|
|
2203
|
+
238389289,
|
|
2204
|
+
3353747414,
|
|
2205
|
+
2531188641,
|
|
2206
|
+
2019080857,
|
|
2207
|
+
1475708069,
|
|
2208
|
+
455242339,
|
|
2209
|
+
2609103871,
|
|
2210
|
+
448939670,
|
|
2211
|
+
3451063019,
|
|
2212
|
+
1395535956,
|
|
2213
|
+
2413381860,
|
|
2214
|
+
1841049896,
|
|
2215
|
+
1491858159,
|
|
2216
|
+
885456874,
|
|
2217
|
+
4264095073,
|
|
2218
|
+
4001119347,
|
|
2219
|
+
1565136089,
|
|
2220
|
+
3898914787,
|
|
2221
|
+
1108368660,
|
|
2222
|
+
540939232,
|
|
2223
|
+
1173283510,
|
|
2224
|
+
2745871338,
|
|
2225
|
+
3681308437,
|
|
2226
|
+
4207628240,
|
|
2227
|
+
3343053890,
|
|
2228
|
+
4016749493,
|
|
2229
|
+
1699691293,
|
|
2230
|
+
1103962373,
|
|
2231
|
+
3625875870,
|
|
2232
|
+
2256883143,
|
|
2233
|
+
3830138730,
|
|
2234
|
+
1031889488,
|
|
2235
|
+
3479347698,
|
|
2236
|
+
1535977030,
|
|
2237
|
+
4236805024,
|
|
2238
|
+
3251091107,
|
|
2239
|
+
2132092099,
|
|
2240
|
+
1774941330,
|
|
2241
|
+
1199868427,
|
|
2242
|
+
1452454533,
|
|
2243
|
+
157007616,
|
|
2244
|
+
2904115357,
|
|
2245
|
+
342012276,
|
|
2246
|
+
595725824,
|
|
2247
|
+
1480756522,
|
|
2248
|
+
206960106,
|
|
2249
|
+
497939518,
|
|
2250
|
+
591360097,
|
|
2251
|
+
863170706,
|
|
2252
|
+
2375253569,
|
|
2253
|
+
3596610801,
|
|
2254
|
+
1814182875,
|
|
2255
|
+
2094937945,
|
|
2256
|
+
3421402208,
|
|
2257
|
+
1082520231,
|
|
2258
|
+
3463918190,
|
|
2259
|
+
2785509508,
|
|
2260
|
+
435703966,
|
|
2261
|
+
3908032597,
|
|
2262
|
+
1641649973,
|
|
2263
|
+
2842273706,
|
|
2264
|
+
3305899714,
|
|
2265
|
+
1510255612,
|
|
2266
|
+
2148256476,
|
|
2267
|
+
2655287854,
|
|
2268
|
+
3276092548,
|
|
2269
|
+
4258621189,
|
|
2270
|
+
236887753,
|
|
2271
|
+
3681803219,
|
|
2272
|
+
274041037,
|
|
2273
|
+
1734335097,
|
|
2274
|
+
3815195456,
|
|
2275
|
+
3317970021,
|
|
2276
|
+
1899903192,
|
|
2277
|
+
1026095262,
|
|
2278
|
+
4050517792,
|
|
2279
|
+
356393447,
|
|
2280
|
+
2410691914,
|
|
2281
|
+
3873677099,
|
|
2282
|
+
3682840055,
|
|
2283
|
+
3913112168,
|
|
2284
|
+
2491498743,
|
|
2285
|
+
4132185628,
|
|
2286
|
+
2489919796,
|
|
2287
|
+
1091903735,
|
|
2288
|
+
1979897079,
|
|
2289
|
+
3170134830,
|
|
2290
|
+
3567386728,
|
|
2291
|
+
3557303409,
|
|
2292
|
+
857797738,
|
|
2293
|
+
1136121015,
|
|
2294
|
+
1342202287,
|
|
2295
|
+
507115054,
|
|
2296
|
+
2535736646,
|
|
2297
|
+
337727348,
|
|
2298
|
+
3213592640,
|
|
2299
|
+
1301675037,
|
|
2300
|
+
2528481711,
|
|
2301
|
+
1895095763,
|
|
2302
|
+
1721773893,
|
|
2303
|
+
3216771564,
|
|
2304
|
+
62756741,
|
|
2305
|
+
2142006736,
|
|
2306
|
+
835421444,
|
|
2307
|
+
2531993523,
|
|
2308
|
+
1442658625,
|
|
2309
|
+
3659876326,
|
|
2310
|
+
2882144922,
|
|
2311
|
+
676362277,
|
|
2312
|
+
1392781812,
|
|
2313
|
+
170690266,
|
|
2314
|
+
3921047035,
|
|
2315
|
+
1759253602,
|
|
2316
|
+
3611846912,
|
|
2317
|
+
1745797284,
|
|
2318
|
+
664899054,
|
|
2319
|
+
1329594018,
|
|
2320
|
+
3901205900,
|
|
2321
|
+
3045908486,
|
|
2322
|
+
2062866102,
|
|
2323
|
+
2865634940,
|
|
2324
|
+
3543621612,
|
|
2325
|
+
3464012697,
|
|
2326
|
+
1080764994,
|
|
2327
|
+
553557557,
|
|
2328
|
+
3656615353,
|
|
2329
|
+
3996768171,
|
|
2330
|
+
991055499,
|
|
2331
|
+
499776247,
|
|
2332
|
+
1265440854,
|
|
2333
|
+
648242737,
|
|
2334
|
+
3940784050,
|
|
2335
|
+
980351604,
|
|
2336
|
+
3713745714,
|
|
2337
|
+
1749149687,
|
|
2338
|
+
3396870395,
|
|
2339
|
+
4211799374,
|
|
2340
|
+
3640570775,
|
|
2341
|
+
1161844396,
|
|
2342
|
+
3125318951,
|
|
2343
|
+
1431517754,
|
|
2344
|
+
545492359,
|
|
2345
|
+
4268468663,
|
|
2346
|
+
3499529547,
|
|
2347
|
+
1437099964,
|
|
2348
|
+
2702547544,
|
|
2349
|
+
3433638243,
|
|
2350
|
+
2581715763,
|
|
2351
|
+
2787789398,
|
|
2352
|
+
1060185593,
|
|
2353
|
+
1593081372,
|
|
2354
|
+
2418618748,
|
|
2355
|
+
4260947970,
|
|
2356
|
+
69676912,
|
|
2357
|
+
2159744348,
|
|
2358
|
+
86519011,
|
|
2359
|
+
2512459080,
|
|
2360
|
+
3838209314,
|
|
2361
|
+
1220612927,
|
|
2362
|
+
3339683548,
|
|
2363
|
+
133810670,
|
|
2364
|
+
1090789135,
|
|
2365
|
+
1078426020,
|
|
2366
|
+
1569222167,
|
|
2367
|
+
845107691,
|
|
2368
|
+
3583754449,
|
|
2369
|
+
4072456591,
|
|
2370
|
+
1091646820,
|
|
2371
|
+
628848692,
|
|
2372
|
+
1613405280,
|
|
2373
|
+
3757631651,
|
|
2374
|
+
526609435,
|
|
2375
|
+
236106946,
|
|
2376
|
+
48312990,
|
|
2377
|
+
2942717905,
|
|
2378
|
+
3402727701,
|
|
2379
|
+
1797494240,
|
|
2380
|
+
859738849,
|
|
2381
|
+
992217954,
|
|
2382
|
+
4005476642,
|
|
2383
|
+
2243076622,
|
|
2384
|
+
3870952857,
|
|
2385
|
+
3732016268,
|
|
2386
|
+
765654824,
|
|
2387
|
+
3490871365,
|
|
2388
|
+
2511836413,
|
|
2389
|
+
1685915746,
|
|
2390
|
+
3888969200,
|
|
2391
|
+
1414112111,
|
|
2392
|
+
2273134842,
|
|
2393
|
+
3281911079,
|
|
2394
|
+
4080962846,
|
|
2395
|
+
172450625,
|
|
2396
|
+
2569994100,
|
|
2397
|
+
980381355,
|
|
2398
|
+
4109958455,
|
|
2399
|
+
2819808352,
|
|
2400
|
+
2716589560,
|
|
2401
|
+
2568741196,
|
|
2402
|
+
3681446669,
|
|
2403
|
+
3329971472,
|
|
2404
|
+
1835478071,
|
|
2405
|
+
660984891,
|
|
2406
|
+
3704678404,
|
|
2407
|
+
4045999559,
|
|
2408
|
+
3422617507,
|
|
2409
|
+
3040415634,
|
|
2410
|
+
1762651403,
|
|
2411
|
+
1719377915,
|
|
2412
|
+
3470491036,
|
|
2413
|
+
2693910283,
|
|
2414
|
+
3642056355,
|
|
2415
|
+
3138596744,
|
|
2416
|
+
1364962596,
|
|
2417
|
+
2073328063,
|
|
2418
|
+
1983633131,
|
|
2419
|
+
926494387,
|
|
2420
|
+
3423689081,
|
|
2421
|
+
2150032023,
|
|
2422
|
+
4096667949,
|
|
2423
|
+
1749200295,
|
|
2424
|
+
3328846651,
|
|
2425
|
+
309677260,
|
|
2426
|
+
2016342300,
|
|
2427
|
+
1779581495,
|
|
2428
|
+
3079819751,
|
|
2429
|
+
111262694,
|
|
2430
|
+
1274766160,
|
|
2431
|
+
443224088,
|
|
2432
|
+
298511866,
|
|
2433
|
+
1025883608,
|
|
2434
|
+
3806446537,
|
|
2435
|
+
1145181785,
|
|
2436
|
+
168956806,
|
|
2437
|
+
3641502830,
|
|
2438
|
+
3584813610,
|
|
2439
|
+
1689216846,
|
|
2440
|
+
3666258015,
|
|
2441
|
+
3200248200,
|
|
2442
|
+
1692713982,
|
|
2443
|
+
2646376535,
|
|
2444
|
+
4042768518,
|
|
2445
|
+
1618508792,
|
|
2446
|
+
1610833997,
|
|
2447
|
+
3523052358,
|
|
2448
|
+
4130873264,
|
|
2449
|
+
2001055236,
|
|
2450
|
+
3610705100,
|
|
2451
|
+
2202168115,
|
|
2452
|
+
4028541809,
|
|
2453
|
+
2961195399,
|
|
2454
|
+
1006657119,
|
|
2455
|
+
2006996926,
|
|
2456
|
+
3186142756,
|
|
2457
|
+
1430667929,
|
|
2458
|
+
3210227297,
|
|
2459
|
+
1314452623,
|
|
2460
|
+
4074634658,
|
|
2461
|
+
4101304120,
|
|
2462
|
+
2273951170,
|
|
2463
|
+
1399257539,
|
|
2464
|
+
3367210612,
|
|
2465
|
+
3027628629,
|
|
2466
|
+
1190975929,
|
|
2467
|
+
2062231137,
|
|
2468
|
+
2333990788,
|
|
2469
|
+
2221543033,
|
|
2470
|
+
2438960610,
|
|
2471
|
+
1181637006,
|
|
2472
|
+
548689776,
|
|
2473
|
+
2362791313,
|
|
2474
|
+
3372408396,
|
|
2475
|
+
3104550113,
|
|
2476
|
+
3145860560,
|
|
2477
|
+
296247880,
|
|
2478
|
+
1970579870,
|
|
2479
|
+
3078560182,
|
|
2480
|
+
3769228297,
|
|
2481
|
+
1714227617,
|
|
2482
|
+
3291629107,
|
|
2483
|
+
3898220290,
|
|
2484
|
+
166772364,
|
|
2485
|
+
1251581989,
|
|
2486
|
+
493813264,
|
|
2487
|
+
448347421,
|
|
2488
|
+
195405023,
|
|
2489
|
+
2709975567,
|
|
2490
|
+
677966185,
|
|
2491
|
+
3703036547,
|
|
2492
|
+
1463355134,
|
|
2493
|
+
2715995803,
|
|
2494
|
+
1338867538,
|
|
2495
|
+
1343315457,
|
|
2496
|
+
2802222074,
|
|
2497
|
+
2684532164,
|
|
2498
|
+
233230375,
|
|
2499
|
+
2599980071,
|
|
2500
|
+
2000651841,
|
|
2501
|
+
3277868038,
|
|
2502
|
+
1638401717,
|
|
2503
|
+
4028070440,
|
|
2504
|
+
3237316320,
|
|
2505
|
+
6314154,
|
|
2506
|
+
819756386,
|
|
2507
|
+
300326615,
|
|
2508
|
+
590932579,
|
|
2509
|
+
1405279636,
|
|
2510
|
+
3267499572,
|
|
2511
|
+
3150704214,
|
|
2512
|
+
2428286686,
|
|
2513
|
+
3959192993,
|
|
2514
|
+
3461946742,
|
|
2515
|
+
1862657033,
|
|
2516
|
+
1266418056,
|
|
2517
|
+
963775037,
|
|
2518
|
+
2089974820,
|
|
2519
|
+
2263052895,
|
|
2520
|
+
1917689273,
|
|
2521
|
+
448879540,
|
|
2522
|
+
3550394620,
|
|
2523
|
+
3981727096,
|
|
2524
|
+
150775221,
|
|
2525
|
+
3627908307,
|
|
2526
|
+
1303187396,
|
|
2527
|
+
508620638,
|
|
2528
|
+
2975983352,
|
|
2529
|
+
2726630617,
|
|
2530
|
+
1817252668,
|
|
2531
|
+
1876281319,
|
|
2532
|
+
1457606340,
|
|
2533
|
+
908771278,
|
|
2534
|
+
3720792119,
|
|
2535
|
+
3617206836,
|
|
2536
|
+
2455994898,
|
|
2537
|
+
1729034894,
|
|
2538
|
+
1080033504,
|
|
2539
|
+
976866871,
|
|
2540
|
+
3556439503,
|
|
2541
|
+
2881648439,
|
|
2542
|
+
1522871579,
|
|
2543
|
+
1555064734,
|
|
2544
|
+
1336096578,
|
|
2545
|
+
3548522304,
|
|
2546
|
+
2579274686,
|
|
2547
|
+
3574697629,
|
|
2548
|
+
3205460757,
|
|
2549
|
+
3593280638,
|
|
2550
|
+
3338716283,
|
|
2551
|
+
3079412587,
|
|
2552
|
+
564236357,
|
|
2553
|
+
2993598910,
|
|
2554
|
+
1781952180,
|
|
2555
|
+
1464380207,
|
|
2556
|
+
3163844217,
|
|
2557
|
+
3332601554,
|
|
2558
|
+
1699332808,
|
|
2559
|
+
1393555694,
|
|
2560
|
+
1183702653,
|
|
2561
|
+
3581086237,
|
|
2562
|
+
1288719814,
|
|
2563
|
+
691649499,
|
|
2564
|
+
2847557200,
|
|
2565
|
+
2895455976,
|
|
2566
|
+
3193889540,
|
|
2567
|
+
2717570544,
|
|
2568
|
+
1781354906,
|
|
2569
|
+
1676643554,
|
|
2570
|
+
2592534050,
|
|
2571
|
+
3230253752,
|
|
2572
|
+
1126444790,
|
|
2573
|
+
2770207658,
|
|
2574
|
+
2633158820,
|
|
2575
|
+
2210423226,
|
|
2576
|
+
2615765581,
|
|
2577
|
+
2414155088,
|
|
2578
|
+
3127139286,
|
|
2579
|
+
673620729,
|
|
2580
|
+
2805611233,
|
|
2581
|
+
1269405062,
|
|
2582
|
+
4015350505,
|
|
2583
|
+
3341807571,
|
|
2584
|
+
4149409754,
|
|
2585
|
+
1057255273,
|
|
2586
|
+
2012875353,
|
|
2587
|
+
2162469141,
|
|
2588
|
+
2276492801,
|
|
2589
|
+
2601117357,
|
|
2590
|
+
993977747,
|
|
2591
|
+
3918593370,
|
|
2592
|
+
2654263191,
|
|
2593
|
+
753973209,
|
|
2594
|
+
36408145,
|
|
2595
|
+
2530585658,
|
|
2596
|
+
25011837,
|
|
2597
|
+
3520020182,
|
|
2598
|
+
2088578344,
|
|
2599
|
+
530523599,
|
|
2600
|
+
2918365339,
|
|
2601
|
+
1524020338,
|
|
2602
|
+
1518925132,
|
|
2603
|
+
3760827505,
|
|
2604
|
+
3759777254,
|
|
2605
|
+
1202760957,
|
|
2606
|
+
3985898139,
|
|
2607
|
+
3906192525,
|
|
2608
|
+
674977740,
|
|
2609
|
+
4174734889,
|
|
2610
|
+
2031300136,
|
|
2611
|
+
2019492241,
|
|
2612
|
+
3983892565,
|
|
2613
|
+
4153806404,
|
|
2614
|
+
3822280332,
|
|
2615
|
+
352677332,
|
|
2616
|
+
2297720250,
|
|
2617
|
+
60907813,
|
|
2618
|
+
90501309,
|
|
2619
|
+
3286998549,
|
|
2620
|
+
1016092578,
|
|
2621
|
+
2535922412,
|
|
2622
|
+
2839152426,
|
|
2623
|
+
457141659,
|
|
2624
|
+
509813237,
|
|
2625
|
+
4120667899,
|
|
2626
|
+
652014361,
|
|
2627
|
+
1966332200,
|
|
2628
|
+
2975202805,
|
|
2629
|
+
55981186,
|
|
2630
|
+
2327461051,
|
|
2631
|
+
676427537,
|
|
2632
|
+
3255491064,
|
|
2633
|
+
2882294119,
|
|
2634
|
+
3433927263,
|
|
2635
|
+
1307055953,
|
|
2636
|
+
942726286,
|
|
2637
|
+
933058658,
|
|
2638
|
+
2468411793,
|
|
2639
|
+
3933900994,
|
|
2640
|
+
4215176142,
|
|
2641
|
+
1361170020,
|
|
2642
|
+
2001714738,
|
|
2643
|
+
2830558078,
|
|
2644
|
+
3274259782,
|
|
2645
|
+
1222529897,
|
|
2646
|
+
1679025792,
|
|
2647
|
+
2729314320,
|
|
2648
|
+
3714953764,
|
|
2649
|
+
1770335741,
|
|
2650
|
+
151462246,
|
|
2651
|
+
3013232138,
|
|
2652
|
+
1682292957,
|
|
2653
|
+
1483529935,
|
|
2654
|
+
471910574,
|
|
2655
|
+
1539241949,
|
|
2656
|
+
458788160,
|
|
2657
|
+
3436315007,
|
|
2658
|
+
1807016891,
|
|
2659
|
+
3718408830,
|
|
2660
|
+
978976581,
|
|
2661
|
+
1043663428,
|
|
2662
|
+
3165965781,
|
|
2663
|
+
1927990952,
|
|
2664
|
+
4200891579,
|
|
2665
|
+
2372276910,
|
|
2666
|
+
3208408903,
|
|
2667
|
+
3533431907,
|
|
2668
|
+
1412390302,
|
|
2669
|
+
2931980059,
|
|
2670
|
+
4132332400,
|
|
2671
|
+
1947078029,
|
|
2672
|
+
3881505623,
|
|
2673
|
+
4168226417,
|
|
2674
|
+
2941484381,
|
|
2675
|
+
1077988104,
|
|
2676
|
+
1320477388,
|
|
2677
|
+
886195818,
|
|
2678
|
+
18198404,
|
|
2679
|
+
3786409000,
|
|
2680
|
+
2509781533,
|
|
2681
|
+
112762804,
|
|
2682
|
+
3463356488,
|
|
2683
|
+
1866414978,
|
|
2684
|
+
891333506,
|
|
2685
|
+
18488651,
|
|
2686
|
+
661792760,
|
|
2687
|
+
1628790961,
|
|
2688
|
+
3885187036,
|
|
2689
|
+
3141171499,
|
|
2690
|
+
876946877,
|
|
2691
|
+
2693282273,
|
|
2692
|
+
1372485963,
|
|
2693
|
+
791857591,
|
|
2694
|
+
2686433993,
|
|
2695
|
+
3759982718,
|
|
2696
|
+
3167212022,
|
|
2697
|
+
3472953795,
|
|
2698
|
+
2716379847,
|
|
2699
|
+
445679433,
|
|
2700
|
+
3561995674,
|
|
2701
|
+
3504004811,
|
|
2702
|
+
3574258232,
|
|
2703
|
+
54117162,
|
|
2704
|
+
3331405415,
|
|
2705
|
+
2381918588,
|
|
2706
|
+
3769707343,
|
|
2707
|
+
4154350007,
|
|
2708
|
+
1140177722,
|
|
2709
|
+
4074052095,
|
|
2710
|
+
668550556,
|
|
2711
|
+
3214352940,
|
|
2712
|
+
367459370,
|
|
2713
|
+
261225585,
|
|
2714
|
+
2610173221,
|
|
2715
|
+
4209349473,
|
|
2716
|
+
3468074219,
|
|
2717
|
+
3265815641,
|
|
2718
|
+
314222801,
|
|
2719
|
+
3066103646,
|
|
2720
|
+
3808782860,
|
|
2721
|
+
282218597,
|
|
2722
|
+
3406013506,
|
|
2723
|
+
3773591054,
|
|
2724
|
+
379116347,
|
|
2725
|
+
1285071038,
|
|
2726
|
+
846784868,
|
|
2727
|
+
2669647154,
|
|
2728
|
+
3771962079,
|
|
2729
|
+
3550491691,
|
|
2730
|
+
2305946142,
|
|
2731
|
+
453669953,
|
|
2732
|
+
1268987020,
|
|
2733
|
+
3317592352,
|
|
2734
|
+
3279303384,
|
|
2735
|
+
3744833421,
|
|
2736
|
+
2610507566,
|
|
2737
|
+
3859509063,
|
|
2738
|
+
266596637,
|
|
2739
|
+
3847019092,
|
|
2740
|
+
517658769,
|
|
2741
|
+
3462560207,
|
|
2742
|
+
3443424879,
|
|
2743
|
+
370717030,
|
|
2744
|
+
4247526661,
|
|
2745
|
+
2224018117,
|
|
2746
|
+
4143653529,
|
|
2747
|
+
4112773975,
|
|
2748
|
+
2788324899,
|
|
2749
|
+
2477274417,
|
|
2750
|
+
1456262402,
|
|
2751
|
+
2901442914,
|
|
2752
|
+
1517677493,
|
|
2753
|
+
1846949527,
|
|
2754
|
+
2295493580,
|
|
2755
|
+
3734397586,
|
|
2756
|
+
2176403920,
|
|
2757
|
+
1280348187,
|
|
2758
|
+
1908823572,
|
|
2759
|
+
3871786941,
|
|
2760
|
+
846861322,
|
|
2761
|
+
1172426758,
|
|
2762
|
+
3287448474,
|
|
2763
|
+
3383383037,
|
|
2764
|
+
1655181056,
|
|
2765
|
+
3139813346,
|
|
2766
|
+
901632758,
|
|
2767
|
+
1897031941,
|
|
2768
|
+
2986607138,
|
|
2769
|
+
3066810236,
|
|
2770
|
+
3447102507,
|
|
2771
|
+
1393639104,
|
|
2772
|
+
373351379,
|
|
2773
|
+
950779232,
|
|
2774
|
+
625454576,
|
|
2775
|
+
3124240540,
|
|
2776
|
+
4148612726,
|
|
2777
|
+
2007998917,
|
|
2778
|
+
544563296,
|
|
2779
|
+
2244738638,
|
|
2780
|
+
2330496472,
|
|
2781
|
+
2058025392,
|
|
2782
|
+
1291430526,
|
|
2783
|
+
424198748,
|
|
2784
|
+
50039436,
|
|
2785
|
+
29584100,
|
|
2786
|
+
3605783033,
|
|
2787
|
+
2429876329,
|
|
2788
|
+
2791104160,
|
|
2789
|
+
1057563949,
|
|
2790
|
+
3255363231,
|
|
2791
|
+
3075367218,
|
|
2792
|
+
3463963227,
|
|
2793
|
+
1469046755,
|
|
2794
|
+
985887462
|
|
2795
|
+
];
|
|
2796
|
+
var C_ORIG = [
|
|
2797
|
+
1332899944,
|
|
2798
|
+
1700884034,
|
|
2799
|
+
1701343084,
|
|
2800
|
+
1684370003,
|
|
2801
|
+
1668446532,
|
|
2802
|
+
1869963892
|
|
2803
|
+
];
|
|
2804
|
+
function _encipher(lr, off, P, S) {
|
|
2805
|
+
var n, l = lr[off], r = lr[off + 1];
|
|
2806
|
+
l ^= P[0];
|
|
2807
|
+
n = S[l >>> 24];
|
|
2808
|
+
n += S[256 | l >> 16 & 255];
|
|
2809
|
+
n ^= S[512 | l >> 8 & 255];
|
|
2810
|
+
n += S[768 | l & 255];
|
|
2811
|
+
r ^= n ^ P[1];
|
|
2812
|
+
n = S[r >>> 24];
|
|
2813
|
+
n += S[256 | r >> 16 & 255];
|
|
2814
|
+
n ^= S[512 | r >> 8 & 255];
|
|
2815
|
+
n += S[768 | r & 255];
|
|
2816
|
+
l ^= n ^ P[2];
|
|
2817
|
+
n = S[l >>> 24];
|
|
2818
|
+
n += S[256 | l >> 16 & 255];
|
|
2819
|
+
n ^= S[512 | l >> 8 & 255];
|
|
2820
|
+
n += S[768 | l & 255];
|
|
2821
|
+
r ^= n ^ P[3];
|
|
2822
|
+
n = S[r >>> 24];
|
|
2823
|
+
n += S[256 | r >> 16 & 255];
|
|
2824
|
+
n ^= S[512 | r >> 8 & 255];
|
|
2825
|
+
n += S[768 | r & 255];
|
|
2826
|
+
l ^= n ^ P[4];
|
|
2827
|
+
n = S[l >>> 24];
|
|
2828
|
+
n += S[256 | l >> 16 & 255];
|
|
2829
|
+
n ^= S[512 | l >> 8 & 255];
|
|
2830
|
+
n += S[768 | l & 255];
|
|
2831
|
+
r ^= n ^ P[5];
|
|
2832
|
+
n = S[r >>> 24];
|
|
2833
|
+
n += S[256 | r >> 16 & 255];
|
|
2834
|
+
n ^= S[512 | r >> 8 & 255];
|
|
2835
|
+
n += S[768 | r & 255];
|
|
2836
|
+
l ^= n ^ P[6];
|
|
2837
|
+
n = S[l >>> 24];
|
|
2838
|
+
n += S[256 | l >> 16 & 255];
|
|
2839
|
+
n ^= S[512 | l >> 8 & 255];
|
|
2840
|
+
n += S[768 | l & 255];
|
|
2841
|
+
r ^= n ^ P[7];
|
|
2842
|
+
n = S[r >>> 24];
|
|
2843
|
+
n += S[256 | r >> 16 & 255];
|
|
2844
|
+
n ^= S[512 | r >> 8 & 255];
|
|
2845
|
+
n += S[768 | r & 255];
|
|
2846
|
+
l ^= n ^ P[8];
|
|
2847
|
+
n = S[l >>> 24];
|
|
2848
|
+
n += S[256 | l >> 16 & 255];
|
|
2849
|
+
n ^= S[512 | l >> 8 & 255];
|
|
2850
|
+
n += S[768 | l & 255];
|
|
2851
|
+
r ^= n ^ P[9];
|
|
2852
|
+
n = S[r >>> 24];
|
|
2853
|
+
n += S[256 | r >> 16 & 255];
|
|
2854
|
+
n ^= S[512 | r >> 8 & 255];
|
|
2855
|
+
n += S[768 | r & 255];
|
|
2856
|
+
l ^= n ^ P[10];
|
|
2857
|
+
n = S[l >>> 24];
|
|
2858
|
+
n += S[256 | l >> 16 & 255];
|
|
2859
|
+
n ^= S[512 | l >> 8 & 255];
|
|
2860
|
+
n += S[768 | l & 255];
|
|
2861
|
+
r ^= n ^ P[11];
|
|
2862
|
+
n = S[r >>> 24];
|
|
2863
|
+
n += S[256 | r >> 16 & 255];
|
|
2864
|
+
n ^= S[512 | r >> 8 & 255];
|
|
2865
|
+
n += S[768 | r & 255];
|
|
2866
|
+
l ^= n ^ P[12];
|
|
2867
|
+
n = S[l >>> 24];
|
|
2868
|
+
n += S[256 | l >> 16 & 255];
|
|
2869
|
+
n ^= S[512 | l >> 8 & 255];
|
|
2870
|
+
n += S[768 | l & 255];
|
|
2871
|
+
r ^= n ^ P[13];
|
|
2872
|
+
n = S[r >>> 24];
|
|
2873
|
+
n += S[256 | r >> 16 & 255];
|
|
2874
|
+
n ^= S[512 | r >> 8 & 255];
|
|
2875
|
+
n += S[768 | r & 255];
|
|
2876
|
+
l ^= n ^ P[14];
|
|
2877
|
+
n = S[l >>> 24];
|
|
2878
|
+
n += S[256 | l >> 16 & 255];
|
|
2879
|
+
n ^= S[512 | l >> 8 & 255];
|
|
2880
|
+
n += S[768 | l & 255];
|
|
2881
|
+
r ^= n ^ P[15];
|
|
2882
|
+
n = S[r >>> 24];
|
|
2883
|
+
n += S[256 | r >> 16 & 255];
|
|
2884
|
+
n ^= S[512 | r >> 8 & 255];
|
|
2885
|
+
n += S[768 | r & 255];
|
|
2886
|
+
l ^= n ^ P[16];
|
|
2887
|
+
lr[off] = r ^ P[BLOWFISH_NUM_ROUNDS + 1];
|
|
2888
|
+
lr[off + 1] = l;
|
|
2889
|
+
return lr;
|
|
2890
|
+
}
|
|
2891
|
+
function _streamtoword(data, offp) {
|
|
2892
|
+
for (var i = 0, word = 0;i < 4; ++i)
|
|
2893
|
+
word = word << 8 | data[offp] & 255, offp = (offp + 1) % data.length;
|
|
2894
|
+
return { key: word, offp };
|
|
2895
|
+
}
|
|
2896
|
+
function _key(key, P, S) {
|
|
2897
|
+
var offset = 0, lr = [0, 0], plen = P.length, slen = S.length, sw;
|
|
2898
|
+
for (var i = 0;i < plen; i++)
|
|
2899
|
+
sw = _streamtoword(key, offset), offset = sw.offp, P[i] = P[i] ^ sw.key;
|
|
2900
|
+
for (i = 0;i < plen; i += 2)
|
|
2901
|
+
lr = _encipher(lr, 0, P, S), P[i] = lr[0], P[i + 1] = lr[1];
|
|
2902
|
+
for (i = 0;i < slen; i += 2)
|
|
2903
|
+
lr = _encipher(lr, 0, P, S), S[i] = lr[0], S[i + 1] = lr[1];
|
|
2904
|
+
}
|
|
2905
|
+
function _ekskey(data, key, P, S) {
|
|
2906
|
+
var offp = 0, lr = [0, 0], plen = P.length, slen = S.length, sw;
|
|
2907
|
+
for (var i = 0;i < plen; i++)
|
|
2908
|
+
sw = _streamtoword(key, offp), offp = sw.offp, P[i] = P[i] ^ sw.key;
|
|
2909
|
+
offp = 0;
|
|
2910
|
+
for (i = 0;i < plen; i += 2)
|
|
2911
|
+
sw = _streamtoword(data, offp), offp = sw.offp, lr[0] ^= sw.key, sw = _streamtoword(data, offp), offp = sw.offp, lr[1] ^= sw.key, lr = _encipher(lr, 0, P, S), P[i] = lr[0], P[i + 1] = lr[1];
|
|
2912
|
+
for (i = 0;i < slen; i += 2)
|
|
2913
|
+
sw = _streamtoword(data, offp), offp = sw.offp, lr[0] ^= sw.key, sw = _streamtoword(data, offp), offp = sw.offp, lr[1] ^= sw.key, lr = _encipher(lr, 0, P, S), S[i] = lr[0], S[i + 1] = lr[1];
|
|
2914
|
+
}
|
|
2915
|
+
function _crypt(b, salt, rounds, callback, progressCallback) {
|
|
2916
|
+
var cdata = C_ORIG.slice(), clen = cdata.length, err;
|
|
2917
|
+
if (rounds < 4 || rounds > 31) {
|
|
2918
|
+
err = Error("Illegal number of rounds (4-31): " + rounds);
|
|
2919
|
+
if (callback) {
|
|
2920
|
+
nextTick(callback.bind(this, err));
|
|
2921
|
+
return;
|
|
2922
|
+
} else
|
|
2923
|
+
throw err;
|
|
2924
|
+
}
|
|
2925
|
+
if (salt.length !== BCRYPT_SALT_LEN) {
|
|
2926
|
+
err = Error("Illegal salt length: " + salt.length + " != " + BCRYPT_SALT_LEN);
|
|
2927
|
+
if (callback) {
|
|
2928
|
+
nextTick(callback.bind(this, err));
|
|
2929
|
+
return;
|
|
2930
|
+
} else
|
|
2931
|
+
throw err;
|
|
2932
|
+
}
|
|
2933
|
+
rounds = 1 << rounds >>> 0;
|
|
2934
|
+
var P, S, i = 0, j;
|
|
2935
|
+
if (Int32Array) {
|
|
2936
|
+
P = new Int32Array(P_ORIG);
|
|
2937
|
+
S = new Int32Array(S_ORIG);
|
|
2938
|
+
} else {
|
|
2939
|
+
P = P_ORIG.slice();
|
|
2940
|
+
S = S_ORIG.slice();
|
|
2941
|
+
}
|
|
2942
|
+
_ekskey(salt, b, P, S);
|
|
2943
|
+
function next() {
|
|
2944
|
+
if (progressCallback)
|
|
2945
|
+
progressCallback(i / rounds);
|
|
2946
|
+
if (i < rounds) {
|
|
2947
|
+
var start = Date.now();
|
|
2948
|
+
for (;i < rounds; ) {
|
|
2949
|
+
i = i + 1;
|
|
2950
|
+
_key(b, P, S);
|
|
2951
|
+
_key(salt, P, S);
|
|
2952
|
+
if (Date.now() - start > MAX_EXECUTION_TIME)
|
|
2953
|
+
break;
|
|
2954
|
+
}
|
|
2955
|
+
} else {
|
|
2956
|
+
for (i = 0;i < 64; i++)
|
|
2957
|
+
for (j = 0;j < clen >> 1; j++)
|
|
2958
|
+
_encipher(cdata, j << 1, P, S);
|
|
2959
|
+
var ret = [];
|
|
2960
|
+
for (i = 0;i < clen; i++)
|
|
2961
|
+
ret.push((cdata[i] >> 24 & 255) >>> 0), ret.push((cdata[i] >> 16 & 255) >>> 0), ret.push((cdata[i] >> 8 & 255) >>> 0), ret.push((cdata[i] & 255) >>> 0);
|
|
2962
|
+
if (callback) {
|
|
2963
|
+
callback(null, ret);
|
|
2964
|
+
return;
|
|
2965
|
+
} else
|
|
2966
|
+
return ret;
|
|
2967
|
+
}
|
|
2968
|
+
if (callback)
|
|
2969
|
+
nextTick(next);
|
|
2970
|
+
}
|
|
2971
|
+
if (typeof callback !== "undefined") {
|
|
2972
|
+
next();
|
|
2973
|
+
} else {
|
|
2974
|
+
var res;
|
|
2975
|
+
while (true)
|
|
2976
|
+
if (typeof (res = next()) !== "undefined")
|
|
2977
|
+
return res || [];
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
function _hash(s, salt, callback, progressCallback) {
|
|
2981
|
+
var err;
|
|
2982
|
+
if (typeof s !== "string" || typeof salt !== "string") {
|
|
2983
|
+
err = Error("Invalid string / salt: Not a string");
|
|
2984
|
+
if (callback) {
|
|
2985
|
+
nextTick(callback.bind(this, err));
|
|
2986
|
+
return;
|
|
2987
|
+
} else
|
|
2988
|
+
throw err;
|
|
2989
|
+
}
|
|
2990
|
+
var minor, offset;
|
|
2991
|
+
if (salt.charAt(0) !== "$" || salt.charAt(1) !== "2") {
|
|
2992
|
+
err = Error("Invalid salt version: " + salt.substring(0, 2));
|
|
2993
|
+
if (callback) {
|
|
2994
|
+
nextTick(callback.bind(this, err));
|
|
2995
|
+
return;
|
|
2996
|
+
} else
|
|
2997
|
+
throw err;
|
|
2998
|
+
}
|
|
2999
|
+
if (salt.charAt(2) === "$")
|
|
3000
|
+
minor = String.fromCharCode(0), offset = 3;
|
|
3001
|
+
else {
|
|
3002
|
+
minor = salt.charAt(2);
|
|
3003
|
+
if (minor !== "a" && minor !== "b" && minor !== "y" || salt.charAt(3) !== "$") {
|
|
3004
|
+
err = Error("Invalid salt revision: " + salt.substring(2, 4));
|
|
3005
|
+
if (callback) {
|
|
3006
|
+
nextTick(callback.bind(this, err));
|
|
3007
|
+
return;
|
|
3008
|
+
} else
|
|
3009
|
+
throw err;
|
|
3010
|
+
}
|
|
3011
|
+
offset = 4;
|
|
3012
|
+
}
|
|
3013
|
+
if (salt.charAt(offset + 2) > "$") {
|
|
3014
|
+
err = Error("Missing salt rounds");
|
|
3015
|
+
if (callback) {
|
|
3016
|
+
nextTick(callback.bind(this, err));
|
|
3017
|
+
return;
|
|
3018
|
+
} else
|
|
3019
|
+
throw err;
|
|
3020
|
+
}
|
|
3021
|
+
var r1 = parseInt(salt.substring(offset, offset + 1), 10) * 10, r2 = parseInt(salt.substring(offset + 1, offset + 2), 10), rounds = r1 + r2, real_salt = salt.substring(offset + 3, offset + 25);
|
|
3022
|
+
s += minor >= "a" ? "\0" : "";
|
|
3023
|
+
var passwordb = stringToBytes(s), saltb = base64_decode(real_salt, BCRYPT_SALT_LEN);
|
|
3024
|
+
function finish(bytes) {
|
|
3025
|
+
var res = [];
|
|
3026
|
+
res.push("$2");
|
|
3027
|
+
if (minor >= "a")
|
|
3028
|
+
res.push(minor);
|
|
3029
|
+
res.push("$");
|
|
3030
|
+
if (rounds < 10)
|
|
3031
|
+
res.push("0");
|
|
3032
|
+
res.push(rounds.toString());
|
|
3033
|
+
res.push("$");
|
|
3034
|
+
res.push(base64_encode(saltb, saltb.length));
|
|
3035
|
+
res.push(base64_encode(bytes, C_ORIG.length * 4 - 1));
|
|
3036
|
+
return res.join("");
|
|
3037
|
+
}
|
|
3038
|
+
if (typeof callback == "undefined")
|
|
3039
|
+
return finish(_crypt(passwordb, saltb, rounds));
|
|
3040
|
+
else {
|
|
3041
|
+
_crypt(passwordb, saltb, rounds, function(err2, bytes) {
|
|
3042
|
+
if (err2)
|
|
3043
|
+
callback(err2, null);
|
|
3044
|
+
else
|
|
3045
|
+
callback(null, finish(bytes));
|
|
3046
|
+
}, progressCallback);
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
bcrypt.encodeBase64 = base64_encode;
|
|
3050
|
+
bcrypt.decodeBase64 = base64_decode;
|
|
3051
|
+
return bcrypt;
|
|
3052
|
+
});
|
|
3053
|
+
});
|
|
3054
|
+
|
|
3055
|
+
// src/key.ts
|
|
3056
|
+
var enc_utf8 = __toESM(require_enc_utf8(), 1);
|
|
3057
|
+
var enc_base64 = __toESM(require_enc_base64(), 1);
|
|
3058
|
+
import {getRandomValues} from "crypto";
|
|
3059
|
+
function generateAppKey() {
|
|
3060
|
+
const random = getRandomValues(new Uint8Array(32));
|
|
3061
|
+
const encodedWord = enc_utf8.default.parse(random.toString());
|
|
3062
|
+
const key = enc_base64.default.stringify(encodedWord);
|
|
3063
|
+
return `base64:${key}`;
|
|
3064
|
+
}
|
|
3065
|
+
// src/crypt.ts
|
|
3066
|
+
var aes = __toESM(require_aes(), 1);
|
|
3067
|
+
var enc_utf82 = __toESM(require_enc_utf8(), 1);
|
|
3068
|
+
import {env as env2} from "@stacksjs/env";
|
|
3069
|
+
var encrypt = function(message) {
|
|
3070
|
+
const passphrase = env2.APP_KEY;
|
|
3071
|
+
if (!passphrase)
|
|
3072
|
+
throw new Error("APP_KEY is not defined");
|
|
3073
|
+
return aes.default.encrypt(message, passphrase).toString();
|
|
3074
|
+
};
|
|
3075
|
+
var decrypt = function(encrypted) {
|
|
3076
|
+
const passphrase = env2.APP_KEY;
|
|
3077
|
+
if (!passphrase)
|
|
3078
|
+
throw new Error("APP_KEY is not defined");
|
|
3079
|
+
return aes.default.decrypt(encrypted, passphrase).toString(enc_utf82.default);
|
|
3080
|
+
};
|
|
3081
|
+
// src/hash.ts
|
|
3082
|
+
var import_bcryptjs = __toESM(require_bcrypt(), 1);
|
|
3083
|
+
|
|
3084
|
+
// /Users/chrisbreuer/Code/stacks/node_modules/js-base64/base64.mjs
|
|
3085
|
+
var version = "3.7.5";
|
|
3086
|
+
var VERSION = version;
|
|
3087
|
+
var _hasatob = typeof atob === "function";
|
|
3088
|
+
var _hasbtoa = typeof btoa === "function";
|
|
3089
|
+
var _hasBuffer = typeof Buffer === "function";
|
|
3090
|
+
var _TD = typeof TextDecoder === "function" ? new TextDecoder : undefined;
|
|
3091
|
+
var _TE = typeof TextEncoder === "function" ? new TextEncoder : undefined;
|
|
3092
|
+
var b64ch = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
3093
|
+
var b64chs = Array.prototype.slice.call(b64ch);
|
|
3094
|
+
var b64tab = ((a) => {
|
|
3095
|
+
let tab = {};
|
|
3096
|
+
a.forEach((c, i) => tab[c] = i);
|
|
3097
|
+
return tab;
|
|
3098
|
+
})(b64chs);
|
|
3099
|
+
var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
|
|
3100
|
+
var _fromCC = String.fromCharCode.bind(String);
|
|
3101
|
+
var _U8Afrom = typeof Uint8Array.from === "function" ? Uint8Array.from.bind(Uint8Array) : (it) => new Uint8Array(Array.prototype.slice.call(it, 0));
|
|
3102
|
+
var _mkUriSafe = (src) => src.replace(/=/g, "").replace(/[+\/]/g, (m0) => m0 == "+" ? "-" : "_");
|
|
3103
|
+
var _tidyB64 = (s) => s.replace(/[^A-Za-z0-9\+\/]/g, "");
|
|
3104
|
+
var btoaPolyfill = (bin) => {
|
|
3105
|
+
let u32, c0, c1, c2, asc = "";
|
|
3106
|
+
const pad = bin.length % 3;
|
|
3107
|
+
for (let i = 0;i < bin.length; ) {
|
|
3108
|
+
if ((c0 = bin.charCodeAt(i++)) > 255 || (c1 = bin.charCodeAt(i++)) > 255 || (c2 = bin.charCodeAt(i++)) > 255)
|
|
3109
|
+
throw new TypeError("invalid character found");
|
|
3110
|
+
u32 = c0 << 16 | c1 << 8 | c2;
|
|
3111
|
+
asc += b64chs[u32 >> 18 & 63] + b64chs[u32 >> 12 & 63] + b64chs[u32 >> 6 & 63] + b64chs[u32 & 63];
|
|
3112
|
+
}
|
|
3113
|
+
return pad ? asc.slice(0, pad - 3) + "===".substring(pad) : asc;
|
|
3114
|
+
};
|
|
3115
|
+
var _btoa = _hasbtoa ? (bin) => btoa(bin) : _hasBuffer ? (bin) => Buffer.from(bin, "binary").toString("base64") : btoaPolyfill;
|
|
3116
|
+
var _fromUint8Array = _hasBuffer ? (u8a) => Buffer.from(u8a).toString("base64") : (u8a) => {
|
|
3117
|
+
const maxargs = 4096;
|
|
3118
|
+
let strs = [];
|
|
3119
|
+
for (let i = 0, l = u8a.length;i < l; i += maxargs) {
|
|
3120
|
+
strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));
|
|
3121
|
+
}
|
|
3122
|
+
return _btoa(strs.join(""));
|
|
3123
|
+
};
|
|
3124
|
+
var fromUint8Array = (u8a, urlsafe = false) => urlsafe ? _mkUriSafe(_fromUint8Array(u8a)) : _fromUint8Array(u8a);
|
|
3125
|
+
var cb_utob = (c) => {
|
|
3126
|
+
if (c.length < 2) {
|
|
3127
|
+
var cc = c.charCodeAt(0);
|
|
3128
|
+
return cc < 128 ? c : cc < 2048 ? _fromCC(192 | cc >>> 6) + _fromCC(128 | cc & 63) : _fromCC(224 | cc >>> 12 & 15) + _fromCC(128 | cc >>> 6 & 63) + _fromCC(128 | cc & 63);
|
|
3129
|
+
} else {
|
|
3130
|
+
var cc = 65536 + (c.charCodeAt(0) - 55296) * 1024 + (c.charCodeAt(1) - 56320);
|
|
3131
|
+
return _fromCC(240 | cc >>> 18 & 7) + _fromCC(128 | cc >>> 12 & 63) + _fromCC(128 | cc >>> 6 & 63) + _fromCC(128 | cc & 63);
|
|
3132
|
+
}
|
|
3133
|
+
};
|
|
3134
|
+
var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
|
|
3135
|
+
var utob = (u) => u.replace(re_utob, cb_utob);
|
|
3136
|
+
var _encode = _hasBuffer ? (s) => Buffer.from(s, "utf8").toString("base64") : _TE ? (s) => _fromUint8Array(_TE.encode(s)) : (s) => _btoa(utob(s));
|
|
3137
|
+
var encode = (src, urlsafe = false) => urlsafe ? _mkUriSafe(_encode(src)) : _encode(src);
|
|
3138
|
+
var encodeURI = (src) => encode(src, true);
|
|
3139
|
+
var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
|
|
3140
|
+
var cb_btou = (cccc) => {
|
|
3141
|
+
switch (cccc.length) {
|
|
3142
|
+
case 4:
|
|
3143
|
+
var cp = (7 & cccc.charCodeAt(0)) << 18 | (63 & cccc.charCodeAt(1)) << 12 | (63 & cccc.charCodeAt(2)) << 6 | 63 & cccc.charCodeAt(3), offset = cp - 65536;
|
|
3144
|
+
return _fromCC((offset >>> 10) + 55296) + _fromCC((offset & 1023) + 56320);
|
|
3145
|
+
case 3:
|
|
3146
|
+
return _fromCC((15 & cccc.charCodeAt(0)) << 12 | (63 & cccc.charCodeAt(1)) << 6 | 63 & cccc.charCodeAt(2));
|
|
3147
|
+
default:
|
|
3148
|
+
return _fromCC((31 & cccc.charCodeAt(0)) << 6 | 63 & cccc.charCodeAt(1));
|
|
3149
|
+
}
|
|
3150
|
+
};
|
|
3151
|
+
var btou = (b) => b.replace(re_btou, cb_btou);
|
|
3152
|
+
var atobPolyfill = (asc) => {
|
|
3153
|
+
asc = asc.replace(/\s+/g, "");
|
|
3154
|
+
if (!b64re.test(asc))
|
|
3155
|
+
throw new TypeError("malformed base64.");
|
|
3156
|
+
asc += "==".slice(2 - (asc.length & 3));
|
|
3157
|
+
let u24, bin = "", r1, r2;
|
|
3158
|
+
for (let i = 0;i < asc.length; ) {
|
|
3159
|
+
u24 = b64tab[asc.charAt(i++)] << 18 | b64tab[asc.charAt(i++)] << 12 | (r1 = b64tab[asc.charAt(i++)]) << 6 | (r2 = b64tab[asc.charAt(i++)]);
|
|
3160
|
+
bin += r1 === 64 ? _fromCC(u24 >> 16 & 255) : r2 === 64 ? _fromCC(u24 >> 16 & 255, u24 >> 8 & 255) : _fromCC(u24 >> 16 & 255, u24 >> 8 & 255, u24 & 255);
|
|
3161
|
+
}
|
|
3162
|
+
return bin;
|
|
3163
|
+
};
|
|
3164
|
+
var _atob = _hasatob ? (asc) => atob(_tidyB64(asc)) : _hasBuffer ? (asc) => Buffer.from(asc, "base64").toString("binary") : atobPolyfill;
|
|
3165
|
+
var _toUint8Array = _hasBuffer ? (a) => _U8Afrom(Buffer.from(a, "base64")) : (a) => _U8Afrom(_atob(a).split("").map((c) => c.charCodeAt(0)));
|
|
3166
|
+
var toUint8Array = (a) => _toUint8Array(_unURI(a));
|
|
3167
|
+
var _decode = _hasBuffer ? (a) => Buffer.from(a, "base64").toString("utf8") : _TD ? (a) => _TD.decode(_toUint8Array(a)) : (a) => btou(_atob(a));
|
|
3168
|
+
var _unURI = (a) => _tidyB64(a.replace(/[-_]/g, (m0) => m0 == "-" ? "+" : "/"));
|
|
3169
|
+
var decode = (src) => _decode(_unURI(src));
|
|
3170
|
+
var isValid = (src) => {
|
|
3171
|
+
if (typeof src !== "string")
|
|
3172
|
+
return false;
|
|
3173
|
+
const s = src.replace(/\s+/g, "").replace(/={0,2}$/, "");
|
|
3174
|
+
return !/[^\s0-9a-zA-Z\+/]/.test(s) || !/[^\s0-9a-zA-Z\-_]/.test(s);
|
|
3175
|
+
};
|
|
3176
|
+
var _noEnum = (v) => {
|
|
3177
|
+
return {
|
|
3178
|
+
value: v,
|
|
3179
|
+
enumerable: false,
|
|
3180
|
+
writable: true,
|
|
3181
|
+
configurable: true
|
|
3182
|
+
};
|
|
3183
|
+
};
|
|
3184
|
+
var extendString = function() {
|
|
3185
|
+
const _add = (name, body) => Object.defineProperty(String.prototype, name, _noEnum(body));
|
|
3186
|
+
_add("fromBase64", function() {
|
|
3187
|
+
return decode(this);
|
|
3188
|
+
});
|
|
3189
|
+
_add("toBase64", function(urlsafe) {
|
|
3190
|
+
return encode(this, urlsafe);
|
|
3191
|
+
});
|
|
3192
|
+
_add("toBase64URI", function() {
|
|
3193
|
+
return encode(this, true);
|
|
3194
|
+
});
|
|
3195
|
+
_add("toBase64URL", function() {
|
|
3196
|
+
return encode(this, true);
|
|
3197
|
+
});
|
|
3198
|
+
_add("toUint8Array", function() {
|
|
3199
|
+
return toUint8Array(this);
|
|
3200
|
+
});
|
|
3201
|
+
};
|
|
3202
|
+
var extendUint8Array = function() {
|
|
3203
|
+
const _add = (name, body) => Object.defineProperty(Uint8Array.prototype, name, _noEnum(body));
|
|
3204
|
+
_add("toBase64", function(urlsafe) {
|
|
3205
|
+
return fromUint8Array(this, urlsafe);
|
|
3206
|
+
});
|
|
3207
|
+
_add("toBase64URI", function() {
|
|
3208
|
+
return fromUint8Array(this, true);
|
|
3209
|
+
});
|
|
3210
|
+
_add("toBase64URL", function() {
|
|
3211
|
+
return fromUint8Array(this, true);
|
|
3212
|
+
});
|
|
3213
|
+
};
|
|
3214
|
+
var extendBuiltins = () => {
|
|
3215
|
+
extendString();
|
|
3216
|
+
extendUint8Array();
|
|
3217
|
+
};
|
|
3218
|
+
var gBase64 = {
|
|
3219
|
+
version,
|
|
3220
|
+
VERSION,
|
|
3221
|
+
atob: _atob,
|
|
3222
|
+
atobPolyfill,
|
|
3223
|
+
btoa: _btoa,
|
|
3224
|
+
btoaPolyfill,
|
|
3225
|
+
fromBase64: decode,
|
|
3226
|
+
toBase64: encode,
|
|
3227
|
+
encode,
|
|
3228
|
+
encodeURI,
|
|
3229
|
+
encodeURL: encodeURI,
|
|
3230
|
+
utob,
|
|
3231
|
+
btou,
|
|
3232
|
+
decode,
|
|
3233
|
+
isValid,
|
|
3234
|
+
fromUint8Array,
|
|
3235
|
+
toUint8Array,
|
|
3236
|
+
extendString,
|
|
3237
|
+
extendUint8Array,
|
|
3238
|
+
extendBuiltins
|
|
3239
|
+
};
|
|
3240
|
+
|
|
3241
|
+
// src/hash.ts
|
|
3242
|
+
var md5 = __toESM(require_md5(), 1);
|
|
3243
|
+
import {hashing} from "@stacksjs/config";
|
|
3244
|
+
async function make(password, algorithm = "bcrypt") {
|
|
3245
|
+
if (algorithm === "bcrypt")
|
|
3246
|
+
return bcryptEncode(password);
|
|
3247
|
+
if (algorithm === "base64")
|
|
3248
|
+
return base64Encode(password);
|
|
3249
|
+
throw new Error("Unsupported algorithm");
|
|
3250
|
+
}
|
|
3251
|
+
async function verify(password, hash, algorithm) {
|
|
3252
|
+
if (algorithm === "bcrypt")
|
|
3253
|
+
return bcryptVerify(password, hash);
|
|
3254
|
+
if (algorithm === "base64")
|
|
3255
|
+
return base64Verify(password, hash);
|
|
3256
|
+
throw new Error("Unsupported algorithm");
|
|
3257
|
+
}
|
|
3258
|
+
async function bcryptEncode(password) {
|
|
3259
|
+
if (!hashing.bcrypt)
|
|
3260
|
+
throw new Error("Bcrypt hashing is not configured");
|
|
3261
|
+
const salt = import_bcryptjs.default.genSaltSync(hashing.bcrypt.rounds);
|
|
3262
|
+
const hash = await import_bcryptjs.default.hash(password, salt);
|
|
3263
|
+
return hash;
|
|
3264
|
+
}
|
|
3265
|
+
async function bcryptVerify(password, hash) {
|
|
3266
|
+
return await import_bcryptjs.default.compare(password, hash);
|
|
3267
|
+
}
|
|
3268
|
+
var base64Encode = function(password) {
|
|
3269
|
+
return gBase64.encode(password);
|
|
3270
|
+
};
|
|
3271
|
+
var base64Verify = function(password, hash) {
|
|
3272
|
+
return gBase64.decode(hash) === password;
|
|
3273
|
+
};
|
|
3274
|
+
var md5Encode = function(password) {
|
|
3275
|
+
return md5.default(password);
|
|
3276
|
+
};
|
|
3277
|
+
export {
|
|
3278
|
+
verify as verifyHash,
|
|
3279
|
+
md5Encode,
|
|
3280
|
+
make as makeHash,
|
|
3281
|
+
generateAppKey,
|
|
3282
|
+
encrypt,
|
|
3283
|
+
decrypt,
|
|
3284
|
+
bcryptVerify,
|
|
3285
|
+
bcryptEncode,
|
|
3286
|
+
base64Verify,
|
|
3287
|
+
base64Encode
|
|
3288
|
+
};
|