@fast-china/utils 2.1.5 → 2.1.7
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/CHANGELOG.md +15 -0
- package/README.md +14 -4
- package/README.zh.md +14 -4
- package/THIRD_PARTY_LICENSES.md +26 -0
- package/dist/crypto/index.mjs +2240 -33
- package/dist/crypto/index.mjs.map +1 -1
- package/dist/dom/index.mjs +2 -0
- package/dist/index.d.mts +1918 -26
- package/dist/index.global.min.js +1 -1
- package/dist/index.global.min.js.map +1 -1
- package/dist/index.mjs +9 -1
- package/dist/internal/runtime.mjs.map +1 -1
- package/dist/vue/breakpoints.mjs +46 -0
- package/dist/vue/breakpoints.mjs.map +1 -0
- package/dist/vue/element-size.mjs +33 -0
- package/dist/vue/element-size.mjs.map +1 -0
- package/dist/vue/event-listener.mjs +30 -0
- package/dist/vue/event-listener.mjs.map +1 -0
- package/dist/vue/index.mjs +15 -0
- package/dist/vue/now.mjs +29 -0
- package/dist/vue/now.mjs.map +1 -0
- package/dist/vue/resize-observer.mjs +31 -0
- package/dist/vue/resize-observer.mjs.map +1 -0
- package/dist/vue/window-size.mjs +32 -0
- package/dist/vue/window-size.mjs.map +1 -0
- package/package.json +4 -6
- package/dist/array/index.d.mts +0 -94
- package/dist/async/index.d.mts +0 -145
- package/dist/base64/index.d.mts +0 -106
- package/dist/color/index.d.mts +0 -89
- package/dist/crypto/index.d.mts +0 -327
- package/dist/date/index.d.mts +0 -190
- package/dist/dom/style.d.mts +0 -29
- package/dist/env/index.d.mts +0 -62
- package/dist/function/index.d.mts +0 -13
- package/dist/identity/index.d.mts +0 -77
- package/dist/internal/text.d.mts +0 -15
- package/dist/logger/index.d.mts +0 -90
- package/dist/number/index.d.mts +0 -89
- package/dist/object/index.d.mts +0 -114
- package/dist/storage/index.d.mts +0 -115
- package/dist/string/index.d.mts +0 -141
- package/dist/vue/emits.d.mts +0 -23
- package/dist/vue/expose.d.mts +0 -11
- package/dist/vue/func.d.mts +0 -13
- package/dist/vue/index.d.mts +0 -9
- package/dist/vue/install.d.mts +0 -50
- package/dist/vue/props.d.mts +0 -22
- package/dist/vue/render.d.mts +0 -11
- package/dist/vue/slots.d.mts +0 -18
- package/dist/vue/with.d.mts +0 -11
- package/docs/API.md +0 -155
- package/docs/API.zh-CN.md +0 -154
- package/docs/DEVELOPMENT_RELEASE.zh-CN.md +0 -65
- package/docs/RUNTIME_CONTRACT.md +0 -42
package/dist/crypto/index.mjs
CHANGED
|
@@ -1,19 +1,2226 @@
|
|
|
1
1
|
import { createDecodedText, encodeUtf8, getTextDecoder } from "../internal/text.mjs";
|
|
2
2
|
import { runtimeGlobals } from "../internal/runtime.mjs";
|
|
3
3
|
import { decodeBase64Bytes, decodeBase64UrlBytes, encodeBase64Bytes, encodeBase64UrlBytes } from "../base64/index.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
//#region \0rolldown/runtime.js
|
|
5
|
+
var __create = Object.create;
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
+
key = keys[i];
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: ((k) => from[k]).bind(null, key),
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
|
|
27
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
28
|
+
throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
29
|
+
});
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/core.js
|
|
32
|
+
var require_core = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
33
|
+
(function(root, factory) {
|
|
34
|
+
if (typeof exports === "object") module.exports = exports = factory();
|
|
35
|
+
else if (typeof define === "function" && define.amd) define([], factory);
|
|
36
|
+
else root.CryptoJS = factory();
|
|
37
|
+
})(exports, function() {
|
|
38
|
+
/**
|
|
39
|
+
* CryptoJS core components.
|
|
40
|
+
*/
|
|
41
|
+
var CryptoJS = CryptoJS || function(Math, undefined) {
|
|
42
|
+
var crypto;
|
|
43
|
+
if (typeof window !== "undefined" && window.crypto) crypto = window.crypto;
|
|
44
|
+
if (typeof self !== "undefined" && self.crypto) crypto = self.crypto;
|
|
45
|
+
if (typeof globalThis !== "undefined" && globalThis.crypto) crypto = globalThis.crypto;
|
|
46
|
+
if (!crypto && typeof window !== "undefined" && window.msCrypto) crypto = window.msCrypto;
|
|
47
|
+
if (!crypto && typeof global !== "undefined" && global.crypto) crypto = global.crypto;
|
|
48
|
+
if (!crypto && typeof __require === "function") try {
|
|
49
|
+
crypto = __require("crypto");
|
|
50
|
+
} catch (err) {}
|
|
51
|
+
var cryptoSecureRandomInt = function() {
|
|
52
|
+
if (crypto) {
|
|
53
|
+
if (typeof crypto.getRandomValues === "function") try {
|
|
54
|
+
return crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0];
|
|
55
|
+
} catch (err) {}
|
|
56
|
+
if (typeof crypto.randomBytes === "function") try {
|
|
57
|
+
return crypto.randomBytes(4).readInt32LE();
|
|
58
|
+
} catch (err) {}
|
|
59
|
+
}
|
|
60
|
+
throw new Error("Native crypto module could not be used to get secure random number.");
|
|
61
|
+
};
|
|
62
|
+
var create = Object.create || function() {
|
|
63
|
+
function F() {}
|
|
64
|
+
return function(obj) {
|
|
65
|
+
var subtype;
|
|
66
|
+
F.prototype = obj;
|
|
67
|
+
subtype = new F();
|
|
68
|
+
F.prototype = null;
|
|
69
|
+
return subtype;
|
|
70
|
+
};
|
|
71
|
+
}();
|
|
72
|
+
/**
|
|
73
|
+
* CryptoJS namespace.
|
|
74
|
+
*/
|
|
75
|
+
var C = {};
|
|
76
|
+
/**
|
|
77
|
+
* Library namespace.
|
|
78
|
+
*/
|
|
79
|
+
var C_lib = C.lib = {};
|
|
80
|
+
/**
|
|
81
|
+
* Base object for prototypal inheritance.
|
|
82
|
+
*/
|
|
83
|
+
var Base = C_lib.Base = function() {
|
|
84
|
+
return {
|
|
85
|
+
/**
|
|
86
|
+
* Creates a new object that inherits from this object.
|
|
87
|
+
*
|
|
88
|
+
* @param {Object} overrides Properties to copy into the new object.
|
|
89
|
+
*
|
|
90
|
+
* @return {Object} The new object.
|
|
91
|
+
*
|
|
92
|
+
* @static
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
*
|
|
96
|
+
* var MyType = CryptoJS.lib.Base.extend({
|
|
97
|
+
* field: 'value',
|
|
98
|
+
*
|
|
99
|
+
* method: function () {
|
|
100
|
+
* }
|
|
101
|
+
* });
|
|
102
|
+
*/
|
|
103
|
+
extend: function(overrides) {
|
|
104
|
+
var subtype = create(this);
|
|
105
|
+
if (overrides) subtype.mixIn(overrides);
|
|
106
|
+
if (!subtype.hasOwnProperty("init") || this.init === subtype.init) subtype.init = function() {
|
|
107
|
+
subtype.$super.init.apply(this, arguments);
|
|
108
|
+
};
|
|
109
|
+
subtype.init.prototype = subtype;
|
|
110
|
+
subtype.$super = this;
|
|
111
|
+
return subtype;
|
|
112
|
+
},
|
|
113
|
+
/**
|
|
114
|
+
* Extends this object and runs the init method.
|
|
115
|
+
* Arguments to create() will be passed to init().
|
|
116
|
+
*
|
|
117
|
+
* @return {Object} The new object.
|
|
118
|
+
*
|
|
119
|
+
* @static
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
*
|
|
123
|
+
* var instance = MyType.create();
|
|
124
|
+
*/
|
|
125
|
+
create: function() {
|
|
126
|
+
var instance = this.extend();
|
|
127
|
+
instance.init.apply(instance, arguments);
|
|
128
|
+
return instance;
|
|
129
|
+
},
|
|
130
|
+
/**
|
|
131
|
+
* Initializes a newly created object.
|
|
132
|
+
* Override this method to add some logic when your objects are created.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
*
|
|
136
|
+
* var MyType = CryptoJS.lib.Base.extend({
|
|
137
|
+
* init: function () {
|
|
138
|
+
* // ...
|
|
139
|
+
* }
|
|
140
|
+
* });
|
|
141
|
+
*/
|
|
142
|
+
init: function() {},
|
|
143
|
+
/**
|
|
144
|
+
* Copies properties into this object.
|
|
145
|
+
*
|
|
146
|
+
* @param {Object} properties The properties to mix in.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
*
|
|
150
|
+
* MyType.mixIn({
|
|
151
|
+
* field: 'value'
|
|
152
|
+
* });
|
|
153
|
+
*/
|
|
154
|
+
mixIn: function(properties) {
|
|
155
|
+
for (var propertyName in properties) if (properties.hasOwnProperty(propertyName)) this[propertyName] = properties[propertyName];
|
|
156
|
+
if (properties.hasOwnProperty("toString")) this.toString = properties.toString;
|
|
157
|
+
},
|
|
158
|
+
/**
|
|
159
|
+
* Creates a copy of this object.
|
|
160
|
+
*
|
|
161
|
+
* @return {Object} The clone.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
*
|
|
165
|
+
* var clone = instance.clone();
|
|
166
|
+
*/
|
|
167
|
+
clone: function() {
|
|
168
|
+
return this.init.prototype.extend(this);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}();
|
|
172
|
+
/**
|
|
173
|
+
* An array of 32-bit words.
|
|
174
|
+
*
|
|
175
|
+
* @property {Array} words The array of 32-bit words.
|
|
176
|
+
* @property {number} sigBytes The number of significant bytes in this word array.
|
|
177
|
+
*/
|
|
178
|
+
var WordArray = C_lib.WordArray = Base.extend({
|
|
179
|
+
/**
|
|
180
|
+
* Initializes a newly created word array.
|
|
181
|
+
*
|
|
182
|
+
* @param {Array} words (Optional) An array of 32-bit words.
|
|
183
|
+
* @param {number} sigBytes (Optional) The number of significant bytes in the words.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
*
|
|
187
|
+
* var wordArray = CryptoJS.lib.WordArray.create();
|
|
188
|
+
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
|
|
189
|
+
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
|
|
190
|
+
*/
|
|
191
|
+
init: function(words, sigBytes) {
|
|
192
|
+
words = this.words = words || [];
|
|
193
|
+
if (sigBytes != undefined) this.sigBytes = sigBytes;
|
|
194
|
+
else this.sigBytes = words.length * 4;
|
|
195
|
+
},
|
|
196
|
+
/**
|
|
197
|
+
* Converts this word array to a string.
|
|
198
|
+
*
|
|
199
|
+
* @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
|
|
200
|
+
*
|
|
201
|
+
* @return {string} The stringified word array.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
*
|
|
205
|
+
* var string = wordArray + '';
|
|
206
|
+
* var string = wordArray.toString();
|
|
207
|
+
* var string = wordArray.toString(CryptoJS.enc.Utf8);
|
|
208
|
+
*/
|
|
209
|
+
toString: function(encoder) {
|
|
210
|
+
return (encoder || Hex).stringify(this);
|
|
211
|
+
},
|
|
212
|
+
/**
|
|
213
|
+
* Concatenates a word array to this word array.
|
|
214
|
+
*
|
|
215
|
+
* @param {WordArray} wordArray The word array to append.
|
|
216
|
+
*
|
|
217
|
+
* @return {WordArray} This word array.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
*
|
|
221
|
+
* wordArray1.concat(wordArray2);
|
|
222
|
+
*/
|
|
223
|
+
concat: function(wordArray) {
|
|
224
|
+
var thisWords = this.words;
|
|
225
|
+
var thatWords = wordArray.words;
|
|
226
|
+
var thisSigBytes = this.sigBytes;
|
|
227
|
+
var thatSigBytes = wordArray.sigBytes;
|
|
228
|
+
this.clamp();
|
|
229
|
+
if (thisSigBytes % 4) for (var i = 0; i < thatSigBytes; i++) {
|
|
230
|
+
var thatByte = thatWords[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
231
|
+
thisWords[thisSigBytes + i >>> 2] |= thatByte << 24 - (thisSigBytes + i) % 4 * 8;
|
|
232
|
+
}
|
|
233
|
+
else for (var j = 0; j < thatSigBytes; j += 4) thisWords[thisSigBytes + j >>> 2] = thatWords[j >>> 2];
|
|
234
|
+
this.sigBytes += thatSigBytes;
|
|
235
|
+
return this;
|
|
236
|
+
},
|
|
237
|
+
/**
|
|
238
|
+
* Removes insignificant bits.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
*
|
|
242
|
+
* wordArray.clamp();
|
|
243
|
+
*/
|
|
244
|
+
clamp: function() {
|
|
245
|
+
var words = this.words;
|
|
246
|
+
var sigBytes = this.sigBytes;
|
|
247
|
+
words[sigBytes >>> 2] &= 4294967295 << 32 - sigBytes % 4 * 8;
|
|
248
|
+
words.length = Math.ceil(sigBytes / 4);
|
|
249
|
+
},
|
|
250
|
+
/**
|
|
251
|
+
* Creates a copy of this word array.
|
|
252
|
+
*
|
|
253
|
+
* @return {WordArray} The clone.
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
*
|
|
257
|
+
* var clone = wordArray.clone();
|
|
258
|
+
*/
|
|
259
|
+
clone: function() {
|
|
260
|
+
var clone = Base.clone.call(this);
|
|
261
|
+
clone.words = this.words.slice(0);
|
|
262
|
+
return clone;
|
|
263
|
+
},
|
|
264
|
+
/**
|
|
265
|
+
* Creates a word array filled with random bytes.
|
|
266
|
+
*
|
|
267
|
+
* @param {number} nBytes The number of random bytes to generate.
|
|
268
|
+
*
|
|
269
|
+
* @return {WordArray} The random word array.
|
|
270
|
+
*
|
|
271
|
+
* @static
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
*
|
|
275
|
+
* var wordArray = CryptoJS.lib.WordArray.random(16);
|
|
276
|
+
*/
|
|
277
|
+
random: function(nBytes) {
|
|
278
|
+
var words = [];
|
|
279
|
+
for (var i = 0; i < nBytes; i += 4) words.push(cryptoSecureRandomInt());
|
|
280
|
+
return new WordArray.init(words, nBytes);
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
/**
|
|
284
|
+
* Encoder namespace.
|
|
285
|
+
*/
|
|
286
|
+
var C_enc = C.enc = {};
|
|
287
|
+
/**
|
|
288
|
+
* Hex encoding strategy.
|
|
289
|
+
*/
|
|
290
|
+
var Hex = C_enc.Hex = {
|
|
291
|
+
/**
|
|
292
|
+
* Converts a word array to a hex string.
|
|
293
|
+
*
|
|
294
|
+
* @param {WordArray} wordArray The word array.
|
|
295
|
+
*
|
|
296
|
+
* @return {string} The hex string.
|
|
297
|
+
*
|
|
298
|
+
* @static
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
*
|
|
302
|
+
* var hexString = CryptoJS.enc.Hex.stringify(wordArray);
|
|
303
|
+
*/
|
|
304
|
+
stringify: function(wordArray) {
|
|
305
|
+
var words = wordArray.words;
|
|
306
|
+
var sigBytes = wordArray.sigBytes;
|
|
307
|
+
var hexChars = [];
|
|
308
|
+
for (var i = 0; i < sigBytes; i++) {
|
|
309
|
+
var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
310
|
+
hexChars.push((bite >>> 4).toString(16));
|
|
311
|
+
hexChars.push((bite & 15).toString(16));
|
|
312
|
+
}
|
|
313
|
+
return hexChars.join("");
|
|
314
|
+
},
|
|
315
|
+
/**
|
|
316
|
+
* Converts a hex string to a word array.
|
|
317
|
+
*
|
|
318
|
+
* @param {string} hexStr The hex string.
|
|
319
|
+
*
|
|
320
|
+
* @return {WordArray} The word array.
|
|
321
|
+
*
|
|
322
|
+
* @static
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
*
|
|
326
|
+
* var wordArray = CryptoJS.enc.Hex.parse(hexString);
|
|
327
|
+
*/
|
|
328
|
+
parse: function(hexStr) {
|
|
329
|
+
var hexStrLength = hexStr.length;
|
|
330
|
+
var words = [];
|
|
331
|
+
for (var i = 0; i < hexStrLength; i += 2) words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << 24 - i % 8 * 4;
|
|
332
|
+
return new WordArray.init(words, hexStrLength / 2);
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
/**
|
|
336
|
+
* Latin1 encoding strategy.
|
|
337
|
+
*/
|
|
338
|
+
var Latin1 = C_enc.Latin1 = {
|
|
339
|
+
/**
|
|
340
|
+
* Converts a word array to a Latin1 string.
|
|
341
|
+
*
|
|
342
|
+
* @param {WordArray} wordArray The word array.
|
|
343
|
+
*
|
|
344
|
+
* @return {string} The Latin1 string.
|
|
345
|
+
*
|
|
346
|
+
* @static
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
*
|
|
350
|
+
* var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
|
|
351
|
+
*/
|
|
352
|
+
stringify: function(wordArray) {
|
|
353
|
+
var words = wordArray.words;
|
|
354
|
+
var sigBytes = wordArray.sigBytes;
|
|
355
|
+
var latin1Chars = [];
|
|
356
|
+
for (var i = 0; i < sigBytes; i++) {
|
|
357
|
+
var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
358
|
+
latin1Chars.push(String.fromCharCode(bite));
|
|
359
|
+
}
|
|
360
|
+
return latin1Chars.join("");
|
|
361
|
+
},
|
|
362
|
+
/**
|
|
363
|
+
* Converts a Latin1 string to a word array.
|
|
364
|
+
*
|
|
365
|
+
* @param {string} latin1Str The Latin1 string.
|
|
366
|
+
*
|
|
367
|
+
* @return {WordArray} The word array.
|
|
368
|
+
*
|
|
369
|
+
* @static
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
*
|
|
373
|
+
* var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
|
|
374
|
+
*/
|
|
375
|
+
parse: function(latin1Str) {
|
|
376
|
+
var latin1StrLength = latin1Str.length;
|
|
377
|
+
var words = [];
|
|
378
|
+
for (var i = 0; i < latin1StrLength; i++) words[i >>> 2] |= (latin1Str.charCodeAt(i) & 255) << 24 - i % 4 * 8;
|
|
379
|
+
return new WordArray.init(words, latin1StrLength);
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
/**
|
|
383
|
+
* UTF-8 encoding strategy.
|
|
384
|
+
*/
|
|
385
|
+
var Utf8 = C_enc.Utf8 = {
|
|
386
|
+
/**
|
|
387
|
+
* Converts a word array to a UTF-8 string.
|
|
388
|
+
*
|
|
389
|
+
* @param {WordArray} wordArray The word array.
|
|
390
|
+
*
|
|
391
|
+
* @return {string} The UTF-8 string.
|
|
392
|
+
*
|
|
393
|
+
* @static
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
*
|
|
397
|
+
* var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
|
|
398
|
+
*/
|
|
399
|
+
stringify: function(wordArray) {
|
|
400
|
+
try {
|
|
401
|
+
return decodeURIComponent(escape(Latin1.stringify(wordArray)));
|
|
402
|
+
} catch (e) {
|
|
403
|
+
throw new Error("Malformed UTF-8 data");
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
/**
|
|
407
|
+
* Converts a UTF-8 string to a word array.
|
|
408
|
+
*
|
|
409
|
+
* @param {string} utf8Str The UTF-8 string.
|
|
410
|
+
*
|
|
411
|
+
* @return {WordArray} The word array.
|
|
412
|
+
*
|
|
413
|
+
* @static
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
*
|
|
417
|
+
* var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
|
|
418
|
+
*/
|
|
419
|
+
parse: function(utf8Str) {
|
|
420
|
+
return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
/**
|
|
424
|
+
* Abstract buffered block algorithm template.
|
|
425
|
+
*
|
|
426
|
+
* The property blockSize must be implemented in a concrete subtype.
|
|
427
|
+
*
|
|
428
|
+
* @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
|
|
429
|
+
*/
|
|
430
|
+
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
|
|
431
|
+
/**
|
|
432
|
+
* Resets this block algorithm's data buffer to its initial state.
|
|
433
|
+
*
|
|
434
|
+
* @example
|
|
435
|
+
*
|
|
436
|
+
* bufferedBlockAlgorithm.reset();
|
|
437
|
+
*/
|
|
438
|
+
reset: function() {
|
|
439
|
+
this._data = new WordArray.init();
|
|
440
|
+
this._nDataBytes = 0;
|
|
441
|
+
},
|
|
442
|
+
/**
|
|
443
|
+
* Adds new data to this block algorithm's buffer.
|
|
444
|
+
*
|
|
445
|
+
* @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
*
|
|
449
|
+
* bufferedBlockAlgorithm._append('data');
|
|
450
|
+
* bufferedBlockAlgorithm._append(wordArray);
|
|
451
|
+
*/
|
|
452
|
+
_append: function(data) {
|
|
453
|
+
if (typeof data == "string") data = Utf8.parse(data);
|
|
454
|
+
this._data.concat(data);
|
|
455
|
+
this._nDataBytes += data.sigBytes;
|
|
456
|
+
},
|
|
457
|
+
/**
|
|
458
|
+
* Processes available data blocks.
|
|
459
|
+
*
|
|
460
|
+
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
|
|
461
|
+
*
|
|
462
|
+
* @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
|
|
463
|
+
*
|
|
464
|
+
* @return {WordArray} The processed data.
|
|
465
|
+
*
|
|
466
|
+
* @example
|
|
467
|
+
*
|
|
468
|
+
* var processedData = bufferedBlockAlgorithm._process();
|
|
469
|
+
* var processedData = bufferedBlockAlgorithm._process(!!'flush');
|
|
470
|
+
*/
|
|
471
|
+
_process: function(doFlush) {
|
|
472
|
+
var processedWords;
|
|
473
|
+
var data = this._data;
|
|
474
|
+
var dataWords = data.words;
|
|
475
|
+
var dataSigBytes = data.sigBytes;
|
|
476
|
+
var blockSize = this.blockSize;
|
|
477
|
+
var nBlocksReady = dataSigBytes / (blockSize * 4);
|
|
478
|
+
if (doFlush) nBlocksReady = Math.ceil(nBlocksReady);
|
|
479
|
+
else nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
|
|
480
|
+
var nWordsReady = nBlocksReady * blockSize;
|
|
481
|
+
var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
|
|
482
|
+
if (nWordsReady) {
|
|
483
|
+
for (var offset = 0; offset < nWordsReady; offset += blockSize) this._doProcessBlock(dataWords, offset);
|
|
484
|
+
processedWords = dataWords.splice(0, nWordsReady);
|
|
485
|
+
data.sigBytes -= nBytesReady;
|
|
486
|
+
}
|
|
487
|
+
return new WordArray.init(processedWords, nBytesReady);
|
|
488
|
+
},
|
|
489
|
+
/**
|
|
490
|
+
* Creates a copy of this object.
|
|
491
|
+
*
|
|
492
|
+
* @return {Object} The clone.
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
*
|
|
496
|
+
* var clone = bufferedBlockAlgorithm.clone();
|
|
497
|
+
*/
|
|
498
|
+
clone: function() {
|
|
499
|
+
var clone = Base.clone.call(this);
|
|
500
|
+
clone._data = this._data.clone();
|
|
501
|
+
return clone;
|
|
502
|
+
},
|
|
503
|
+
_minBufferSize: 0
|
|
504
|
+
});
|
|
505
|
+
C_lib.Hasher = BufferedBlockAlgorithm.extend({
|
|
506
|
+
/**
|
|
507
|
+
* Configuration options.
|
|
508
|
+
*/
|
|
509
|
+
cfg: Base.extend(),
|
|
510
|
+
/**
|
|
511
|
+
* Initializes a newly created hasher.
|
|
512
|
+
*
|
|
513
|
+
* @param {Object} cfg (Optional) The configuration options to use for this hash computation.
|
|
514
|
+
*
|
|
515
|
+
* @example
|
|
516
|
+
*
|
|
517
|
+
* var hasher = CryptoJS.algo.SHA256.create();
|
|
518
|
+
*/
|
|
519
|
+
init: function(cfg) {
|
|
520
|
+
this.cfg = this.cfg.extend(cfg);
|
|
521
|
+
this.reset();
|
|
522
|
+
},
|
|
523
|
+
/**
|
|
524
|
+
* Resets this hasher to its initial state.
|
|
525
|
+
*
|
|
526
|
+
* @example
|
|
527
|
+
*
|
|
528
|
+
* hasher.reset();
|
|
529
|
+
*/
|
|
530
|
+
reset: function() {
|
|
531
|
+
BufferedBlockAlgorithm.reset.call(this);
|
|
532
|
+
this._doReset();
|
|
533
|
+
},
|
|
534
|
+
/**
|
|
535
|
+
* Updates this hasher with a message.
|
|
536
|
+
*
|
|
537
|
+
* @param {WordArray|string} messageUpdate The message to append.
|
|
538
|
+
*
|
|
539
|
+
* @return {Hasher} This hasher.
|
|
540
|
+
*
|
|
541
|
+
* @example
|
|
542
|
+
*
|
|
543
|
+
* hasher.update('message');
|
|
544
|
+
* hasher.update(wordArray);
|
|
545
|
+
*/
|
|
546
|
+
update: function(messageUpdate) {
|
|
547
|
+
this._append(messageUpdate);
|
|
548
|
+
this._process();
|
|
549
|
+
return this;
|
|
550
|
+
},
|
|
551
|
+
/**
|
|
552
|
+
* Finalizes the hash computation.
|
|
553
|
+
* Note that the finalize operation is effectively a destructive, read-once operation.
|
|
554
|
+
*
|
|
555
|
+
* @param {WordArray|string} messageUpdate (Optional) A final message update.
|
|
556
|
+
*
|
|
557
|
+
* @return {WordArray} The hash.
|
|
558
|
+
*
|
|
559
|
+
* @example
|
|
560
|
+
*
|
|
561
|
+
* var hash = hasher.finalize();
|
|
562
|
+
* var hash = hasher.finalize('message');
|
|
563
|
+
* var hash = hasher.finalize(wordArray);
|
|
564
|
+
*/
|
|
565
|
+
finalize: function(messageUpdate) {
|
|
566
|
+
if (messageUpdate) this._append(messageUpdate);
|
|
567
|
+
return this._doFinalize();
|
|
568
|
+
},
|
|
569
|
+
blockSize: 16,
|
|
570
|
+
/**
|
|
571
|
+
* Creates a shortcut function to a hasher's object interface.
|
|
572
|
+
*
|
|
573
|
+
* @param {Hasher} hasher The hasher to create a helper for.
|
|
574
|
+
*
|
|
575
|
+
* @return {Function} The shortcut function.
|
|
576
|
+
*
|
|
577
|
+
* @static
|
|
578
|
+
*
|
|
579
|
+
* @example
|
|
580
|
+
*
|
|
581
|
+
* var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
|
|
582
|
+
*/
|
|
583
|
+
_createHelper: function(hasher) {
|
|
584
|
+
return function(message, cfg) {
|
|
585
|
+
return new hasher.init(cfg).finalize(message);
|
|
586
|
+
};
|
|
587
|
+
},
|
|
588
|
+
/**
|
|
589
|
+
* Creates a shortcut function to the HMAC's object interface.
|
|
590
|
+
*
|
|
591
|
+
* @param {Hasher} hasher The hasher to use in this HMAC helper.
|
|
592
|
+
*
|
|
593
|
+
* @return {Function} The shortcut function.
|
|
594
|
+
*
|
|
595
|
+
* @static
|
|
596
|
+
*
|
|
597
|
+
* @example
|
|
598
|
+
*
|
|
599
|
+
* var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
|
|
600
|
+
*/
|
|
601
|
+
_createHmacHelper: function(hasher) {
|
|
602
|
+
return function(message, key) {
|
|
603
|
+
return new C_algo.HMAC.init(hasher, key).finalize(message);
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
/**
|
|
608
|
+
* Algorithm namespace.
|
|
609
|
+
*/
|
|
610
|
+
var C_algo = C.algo = {};
|
|
611
|
+
return C;
|
|
612
|
+
}(Math);
|
|
613
|
+
return CryptoJS;
|
|
614
|
+
});
|
|
615
|
+
}));
|
|
616
|
+
//#endregion
|
|
617
|
+
//#region node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64.js
|
|
618
|
+
var require_enc_base64 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
619
|
+
(function(root, factory) {
|
|
620
|
+
if (typeof exports === "object") module.exports = exports = factory(require_core());
|
|
621
|
+
else if (typeof define === "function" && define.amd) define(["./core"], factory);
|
|
622
|
+
else factory(root.CryptoJS);
|
|
623
|
+
})(exports, function(CryptoJS) {
|
|
624
|
+
(function() {
|
|
625
|
+
var C = CryptoJS;
|
|
626
|
+
var WordArray = C.lib.WordArray;
|
|
627
|
+
var C_enc = C.enc;
|
|
628
|
+
C_enc.Base64 = {
|
|
629
|
+
/**
|
|
630
|
+
* Converts a word array to a Base64 string.
|
|
631
|
+
*
|
|
632
|
+
* @param {WordArray} wordArray The word array.
|
|
633
|
+
*
|
|
634
|
+
* @return {string} The Base64 string.
|
|
635
|
+
*
|
|
636
|
+
* @static
|
|
637
|
+
*
|
|
638
|
+
* @example
|
|
639
|
+
*
|
|
640
|
+
* var base64String = CryptoJS.enc.Base64.stringify(wordArray);
|
|
641
|
+
*/
|
|
642
|
+
stringify: function(wordArray) {
|
|
643
|
+
var words = wordArray.words;
|
|
644
|
+
var sigBytes = wordArray.sigBytes;
|
|
645
|
+
var map = this._map;
|
|
646
|
+
wordArray.clamp();
|
|
647
|
+
var base64Chars = [];
|
|
648
|
+
for (var i = 0; i < sigBytes; i += 3) {
|
|
649
|
+
var byte1 = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
650
|
+
var byte2 = words[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255;
|
|
651
|
+
var byte3 = words[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255;
|
|
652
|
+
var triplet = byte1 << 16 | byte2 << 8 | byte3;
|
|
653
|
+
for (var j = 0; j < 4 && i + j * .75 < sigBytes; j++) base64Chars.push(map.charAt(triplet >>> 6 * (3 - j) & 63));
|
|
654
|
+
}
|
|
655
|
+
var paddingChar = map.charAt(64);
|
|
656
|
+
if (paddingChar) while (base64Chars.length % 4) base64Chars.push(paddingChar);
|
|
657
|
+
return base64Chars.join("");
|
|
658
|
+
},
|
|
659
|
+
/**
|
|
660
|
+
* Converts a Base64 string to a word array.
|
|
661
|
+
*
|
|
662
|
+
* @param {string} base64Str The Base64 string.
|
|
663
|
+
*
|
|
664
|
+
* @return {WordArray} The word array.
|
|
665
|
+
*
|
|
666
|
+
* @static
|
|
667
|
+
*
|
|
668
|
+
* @example
|
|
669
|
+
*
|
|
670
|
+
* var wordArray = CryptoJS.enc.Base64.parse(base64String);
|
|
671
|
+
*/
|
|
672
|
+
parse: function(base64Str) {
|
|
673
|
+
var base64StrLength = base64Str.length;
|
|
674
|
+
var map = this._map;
|
|
675
|
+
var reverseMap = this._reverseMap;
|
|
676
|
+
if (!reverseMap) {
|
|
677
|
+
reverseMap = this._reverseMap = [];
|
|
678
|
+
for (var j = 0; j < map.length; j++) reverseMap[map.charCodeAt(j)] = j;
|
|
679
|
+
}
|
|
680
|
+
var paddingChar = map.charAt(64);
|
|
681
|
+
if (paddingChar) {
|
|
682
|
+
var paddingIndex = base64Str.indexOf(paddingChar);
|
|
683
|
+
if (paddingIndex !== -1) base64StrLength = paddingIndex;
|
|
684
|
+
}
|
|
685
|
+
return parseLoop(base64Str, base64StrLength, reverseMap);
|
|
686
|
+
},
|
|
687
|
+
_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
|
|
688
|
+
};
|
|
689
|
+
function parseLoop(base64Str, base64StrLength, reverseMap) {
|
|
690
|
+
var words = [];
|
|
691
|
+
var nBytes = 0;
|
|
692
|
+
for (var i = 0; i < base64StrLength; i++) if (i % 4) {
|
|
693
|
+
var bitsCombined = reverseMap[base64Str.charCodeAt(i - 1)] << i % 4 * 2 | reverseMap[base64Str.charCodeAt(i)] >>> 6 - i % 4 * 2;
|
|
694
|
+
words[nBytes >>> 2] |= bitsCombined << 24 - nBytes % 4 * 8;
|
|
695
|
+
nBytes++;
|
|
696
|
+
}
|
|
697
|
+
return WordArray.create(words, nBytes);
|
|
698
|
+
}
|
|
699
|
+
})();
|
|
700
|
+
return CryptoJS.enc.Base64;
|
|
701
|
+
});
|
|
702
|
+
}));
|
|
703
|
+
//#endregion
|
|
704
|
+
//#region node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/md5.js
|
|
705
|
+
var require_md5 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
706
|
+
(function(root, factory) {
|
|
707
|
+
if (typeof exports === "object") module.exports = exports = factory(require_core());
|
|
708
|
+
else if (typeof define === "function" && define.amd) define(["./core"], factory);
|
|
709
|
+
else factory(root.CryptoJS);
|
|
710
|
+
})(exports, function(CryptoJS) {
|
|
711
|
+
(function(Math) {
|
|
712
|
+
var C = CryptoJS;
|
|
713
|
+
var C_lib = C.lib;
|
|
714
|
+
var WordArray = C_lib.WordArray;
|
|
715
|
+
var Hasher = C_lib.Hasher;
|
|
716
|
+
var C_algo = C.algo;
|
|
717
|
+
var T = [];
|
|
718
|
+
(function() {
|
|
719
|
+
for (var i = 0; i < 64; i++) T[i] = Math.abs(Math.sin(i + 1)) * 4294967296 | 0;
|
|
720
|
+
})();
|
|
721
|
+
/**
|
|
722
|
+
* MD5 hash algorithm.
|
|
723
|
+
*/
|
|
724
|
+
var MD5 = C_algo.MD5 = Hasher.extend({
|
|
725
|
+
_doReset: function() {
|
|
726
|
+
this._hash = new WordArray.init([
|
|
727
|
+
1732584193,
|
|
728
|
+
4023233417,
|
|
729
|
+
2562383102,
|
|
730
|
+
271733878
|
|
731
|
+
]);
|
|
732
|
+
},
|
|
733
|
+
_doProcessBlock: function(M, offset) {
|
|
734
|
+
for (var i = 0; i < 16; i++) {
|
|
735
|
+
var offset_i = offset + i;
|
|
736
|
+
var M_offset_i = M[offset_i];
|
|
737
|
+
M[offset_i] = (M_offset_i << 8 | M_offset_i >>> 24) & 16711935 | (M_offset_i << 24 | M_offset_i >>> 8) & 4278255360;
|
|
738
|
+
}
|
|
739
|
+
var H = this._hash.words;
|
|
740
|
+
var M_offset_0 = M[offset + 0];
|
|
741
|
+
var M_offset_1 = M[offset + 1];
|
|
742
|
+
var M_offset_2 = M[offset + 2];
|
|
743
|
+
var M_offset_3 = M[offset + 3];
|
|
744
|
+
var M_offset_4 = M[offset + 4];
|
|
745
|
+
var M_offset_5 = M[offset + 5];
|
|
746
|
+
var M_offset_6 = M[offset + 6];
|
|
747
|
+
var M_offset_7 = M[offset + 7];
|
|
748
|
+
var M_offset_8 = M[offset + 8];
|
|
749
|
+
var M_offset_9 = M[offset + 9];
|
|
750
|
+
var M_offset_10 = M[offset + 10];
|
|
751
|
+
var M_offset_11 = M[offset + 11];
|
|
752
|
+
var M_offset_12 = M[offset + 12];
|
|
753
|
+
var M_offset_13 = M[offset + 13];
|
|
754
|
+
var M_offset_14 = M[offset + 14];
|
|
755
|
+
var M_offset_15 = M[offset + 15];
|
|
756
|
+
var a = H[0];
|
|
757
|
+
var b = H[1];
|
|
758
|
+
var c = H[2];
|
|
759
|
+
var d = H[3];
|
|
760
|
+
a = FF(a, b, c, d, M_offset_0, 7, T[0]);
|
|
761
|
+
d = FF(d, a, b, c, M_offset_1, 12, T[1]);
|
|
762
|
+
c = FF(c, d, a, b, M_offset_2, 17, T[2]);
|
|
763
|
+
b = FF(b, c, d, a, M_offset_3, 22, T[3]);
|
|
764
|
+
a = FF(a, b, c, d, M_offset_4, 7, T[4]);
|
|
765
|
+
d = FF(d, a, b, c, M_offset_5, 12, T[5]);
|
|
766
|
+
c = FF(c, d, a, b, M_offset_6, 17, T[6]);
|
|
767
|
+
b = FF(b, c, d, a, M_offset_7, 22, T[7]);
|
|
768
|
+
a = FF(a, b, c, d, M_offset_8, 7, T[8]);
|
|
769
|
+
d = FF(d, a, b, c, M_offset_9, 12, T[9]);
|
|
770
|
+
c = FF(c, d, a, b, M_offset_10, 17, T[10]);
|
|
771
|
+
b = FF(b, c, d, a, M_offset_11, 22, T[11]);
|
|
772
|
+
a = FF(a, b, c, d, M_offset_12, 7, T[12]);
|
|
773
|
+
d = FF(d, a, b, c, M_offset_13, 12, T[13]);
|
|
774
|
+
c = FF(c, d, a, b, M_offset_14, 17, T[14]);
|
|
775
|
+
b = FF(b, c, d, a, M_offset_15, 22, T[15]);
|
|
776
|
+
a = GG(a, b, c, d, M_offset_1, 5, T[16]);
|
|
777
|
+
d = GG(d, a, b, c, M_offset_6, 9, T[17]);
|
|
778
|
+
c = GG(c, d, a, b, M_offset_11, 14, T[18]);
|
|
779
|
+
b = GG(b, c, d, a, M_offset_0, 20, T[19]);
|
|
780
|
+
a = GG(a, b, c, d, M_offset_5, 5, T[20]);
|
|
781
|
+
d = GG(d, a, b, c, M_offset_10, 9, T[21]);
|
|
782
|
+
c = GG(c, d, a, b, M_offset_15, 14, T[22]);
|
|
783
|
+
b = GG(b, c, d, a, M_offset_4, 20, T[23]);
|
|
784
|
+
a = GG(a, b, c, d, M_offset_9, 5, T[24]);
|
|
785
|
+
d = GG(d, a, b, c, M_offset_14, 9, T[25]);
|
|
786
|
+
c = GG(c, d, a, b, M_offset_3, 14, T[26]);
|
|
787
|
+
b = GG(b, c, d, a, M_offset_8, 20, T[27]);
|
|
788
|
+
a = GG(a, b, c, d, M_offset_13, 5, T[28]);
|
|
789
|
+
d = GG(d, a, b, c, M_offset_2, 9, T[29]);
|
|
790
|
+
c = GG(c, d, a, b, M_offset_7, 14, T[30]);
|
|
791
|
+
b = GG(b, c, d, a, M_offset_12, 20, T[31]);
|
|
792
|
+
a = HH(a, b, c, d, M_offset_5, 4, T[32]);
|
|
793
|
+
d = HH(d, a, b, c, M_offset_8, 11, T[33]);
|
|
794
|
+
c = HH(c, d, a, b, M_offset_11, 16, T[34]);
|
|
795
|
+
b = HH(b, c, d, a, M_offset_14, 23, T[35]);
|
|
796
|
+
a = HH(a, b, c, d, M_offset_1, 4, T[36]);
|
|
797
|
+
d = HH(d, a, b, c, M_offset_4, 11, T[37]);
|
|
798
|
+
c = HH(c, d, a, b, M_offset_7, 16, T[38]);
|
|
799
|
+
b = HH(b, c, d, a, M_offset_10, 23, T[39]);
|
|
800
|
+
a = HH(a, b, c, d, M_offset_13, 4, T[40]);
|
|
801
|
+
d = HH(d, a, b, c, M_offset_0, 11, T[41]);
|
|
802
|
+
c = HH(c, d, a, b, M_offset_3, 16, T[42]);
|
|
803
|
+
b = HH(b, c, d, a, M_offset_6, 23, T[43]);
|
|
804
|
+
a = HH(a, b, c, d, M_offset_9, 4, T[44]);
|
|
805
|
+
d = HH(d, a, b, c, M_offset_12, 11, T[45]);
|
|
806
|
+
c = HH(c, d, a, b, M_offset_15, 16, T[46]);
|
|
807
|
+
b = HH(b, c, d, a, M_offset_2, 23, T[47]);
|
|
808
|
+
a = II(a, b, c, d, M_offset_0, 6, T[48]);
|
|
809
|
+
d = II(d, a, b, c, M_offset_7, 10, T[49]);
|
|
810
|
+
c = II(c, d, a, b, M_offset_14, 15, T[50]);
|
|
811
|
+
b = II(b, c, d, a, M_offset_5, 21, T[51]);
|
|
812
|
+
a = II(a, b, c, d, M_offset_12, 6, T[52]);
|
|
813
|
+
d = II(d, a, b, c, M_offset_3, 10, T[53]);
|
|
814
|
+
c = II(c, d, a, b, M_offset_10, 15, T[54]);
|
|
815
|
+
b = II(b, c, d, a, M_offset_1, 21, T[55]);
|
|
816
|
+
a = II(a, b, c, d, M_offset_8, 6, T[56]);
|
|
817
|
+
d = II(d, a, b, c, M_offset_15, 10, T[57]);
|
|
818
|
+
c = II(c, d, a, b, M_offset_6, 15, T[58]);
|
|
819
|
+
b = II(b, c, d, a, M_offset_13, 21, T[59]);
|
|
820
|
+
a = II(a, b, c, d, M_offset_4, 6, T[60]);
|
|
821
|
+
d = II(d, a, b, c, M_offset_11, 10, T[61]);
|
|
822
|
+
c = II(c, d, a, b, M_offset_2, 15, T[62]);
|
|
823
|
+
b = II(b, c, d, a, M_offset_9, 21, T[63]);
|
|
824
|
+
H[0] = H[0] + a | 0;
|
|
825
|
+
H[1] = H[1] + b | 0;
|
|
826
|
+
H[2] = H[2] + c | 0;
|
|
827
|
+
H[3] = H[3] + d | 0;
|
|
828
|
+
},
|
|
829
|
+
_doFinalize: function() {
|
|
830
|
+
var data = this._data;
|
|
831
|
+
var dataWords = data.words;
|
|
832
|
+
var nBitsTotal = this._nDataBytes * 8;
|
|
833
|
+
var nBitsLeft = data.sigBytes * 8;
|
|
834
|
+
dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
|
|
835
|
+
var nBitsTotalH = Math.floor(nBitsTotal / 4294967296);
|
|
836
|
+
var nBitsTotalL = nBitsTotal;
|
|
837
|
+
dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = (nBitsTotalH << 8 | nBitsTotalH >>> 24) & 16711935 | (nBitsTotalH << 24 | nBitsTotalH >>> 8) & 4278255360;
|
|
838
|
+
dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = (nBitsTotalL << 8 | nBitsTotalL >>> 24) & 16711935 | (nBitsTotalL << 24 | nBitsTotalL >>> 8) & 4278255360;
|
|
839
|
+
data.sigBytes = (dataWords.length + 1) * 4;
|
|
840
|
+
this._process();
|
|
841
|
+
var hash = this._hash;
|
|
842
|
+
var H = hash.words;
|
|
843
|
+
for (var i = 0; i < 4; i++) {
|
|
844
|
+
var H_i = H[i];
|
|
845
|
+
H[i] = (H_i << 8 | H_i >>> 24) & 16711935 | (H_i << 24 | H_i >>> 8) & 4278255360;
|
|
846
|
+
}
|
|
847
|
+
return hash;
|
|
848
|
+
},
|
|
849
|
+
clone: function() {
|
|
850
|
+
var clone = Hasher.clone.call(this);
|
|
851
|
+
clone._hash = this._hash.clone();
|
|
852
|
+
return clone;
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
function FF(a, b, c, d, x, s, t) {
|
|
856
|
+
var n = a + (b & c | ~b & d) + x + t;
|
|
857
|
+
return (n << s | n >>> 32 - s) + b;
|
|
858
|
+
}
|
|
859
|
+
function GG(a, b, c, d, x, s, t) {
|
|
860
|
+
var n = a + (b & d | c & ~d) + x + t;
|
|
861
|
+
return (n << s | n >>> 32 - s) + b;
|
|
862
|
+
}
|
|
863
|
+
function HH(a, b, c, d, x, s, t) {
|
|
864
|
+
var n = a + (b ^ c ^ d) + x + t;
|
|
865
|
+
return (n << s | n >>> 32 - s) + b;
|
|
866
|
+
}
|
|
867
|
+
function II(a, b, c, d, x, s, t) {
|
|
868
|
+
var n = a + (c ^ (b | ~d)) + x + t;
|
|
869
|
+
return (n << s | n >>> 32 - s) + b;
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Shortcut function to the hasher's object interface.
|
|
873
|
+
*
|
|
874
|
+
* @param {WordArray|string} message The message to hash.
|
|
875
|
+
*
|
|
876
|
+
* @return {WordArray} The hash.
|
|
877
|
+
*
|
|
878
|
+
* @static
|
|
879
|
+
*
|
|
880
|
+
* @example
|
|
881
|
+
*
|
|
882
|
+
* var hash = CryptoJS.MD5('message');
|
|
883
|
+
* var hash = CryptoJS.MD5(wordArray);
|
|
884
|
+
*/
|
|
885
|
+
C.MD5 = Hasher._createHelper(MD5);
|
|
886
|
+
/**
|
|
887
|
+
* Shortcut function to the HMAC's object interface.
|
|
888
|
+
*
|
|
889
|
+
* @param {WordArray|string} message The message to hash.
|
|
890
|
+
* @param {WordArray|string} key The secret key.
|
|
891
|
+
*
|
|
892
|
+
* @return {WordArray} The HMAC.
|
|
893
|
+
*
|
|
894
|
+
* @static
|
|
895
|
+
*
|
|
896
|
+
* @example
|
|
897
|
+
*
|
|
898
|
+
* var hmac = CryptoJS.HmacMD5(message, key);
|
|
899
|
+
*/
|
|
900
|
+
C.HmacMD5 = Hasher._createHmacHelper(MD5);
|
|
901
|
+
})(Math);
|
|
902
|
+
return CryptoJS.MD5;
|
|
903
|
+
});
|
|
904
|
+
}));
|
|
905
|
+
//#endregion
|
|
906
|
+
//#region node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha1.js
|
|
907
|
+
var require_sha1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
908
|
+
(function(root, factory) {
|
|
909
|
+
if (typeof exports === "object") module.exports = exports = factory(require_core());
|
|
910
|
+
else if (typeof define === "function" && define.amd) define(["./core"], factory);
|
|
911
|
+
else factory(root.CryptoJS);
|
|
912
|
+
})(exports, function(CryptoJS) {
|
|
913
|
+
(function() {
|
|
914
|
+
var C = CryptoJS;
|
|
915
|
+
var C_lib = C.lib;
|
|
916
|
+
var WordArray = C_lib.WordArray;
|
|
917
|
+
var Hasher = C_lib.Hasher;
|
|
918
|
+
var C_algo = C.algo;
|
|
919
|
+
var W = [];
|
|
920
|
+
/**
|
|
921
|
+
* SHA-1 hash algorithm.
|
|
922
|
+
*/
|
|
923
|
+
var SHA1 = C_algo.SHA1 = Hasher.extend({
|
|
924
|
+
_doReset: function() {
|
|
925
|
+
this._hash = new WordArray.init([
|
|
926
|
+
1732584193,
|
|
927
|
+
4023233417,
|
|
928
|
+
2562383102,
|
|
929
|
+
271733878,
|
|
930
|
+
3285377520
|
|
931
|
+
]);
|
|
932
|
+
},
|
|
933
|
+
_doProcessBlock: function(M, offset) {
|
|
934
|
+
var H = this._hash.words;
|
|
935
|
+
var a = H[0];
|
|
936
|
+
var b = H[1];
|
|
937
|
+
var c = H[2];
|
|
938
|
+
var d = H[3];
|
|
939
|
+
var e = H[4];
|
|
940
|
+
for (var i = 0; i < 80; i++) {
|
|
941
|
+
if (i < 16) W[i] = M[offset + i] | 0;
|
|
942
|
+
else {
|
|
943
|
+
var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
|
|
944
|
+
W[i] = n << 1 | n >>> 31;
|
|
945
|
+
}
|
|
946
|
+
var t = (a << 5 | a >>> 27) + e + W[i];
|
|
947
|
+
if (i < 20) t += (b & c | ~b & d) + 1518500249;
|
|
948
|
+
else if (i < 40) t += (b ^ c ^ d) + 1859775393;
|
|
949
|
+
else if (i < 60) t += (b & c | b & d | c & d) - 1894007588;
|
|
950
|
+
else t += (b ^ c ^ d) - 899497514;
|
|
951
|
+
e = d;
|
|
952
|
+
d = c;
|
|
953
|
+
c = b << 30 | b >>> 2;
|
|
954
|
+
b = a;
|
|
955
|
+
a = t;
|
|
956
|
+
}
|
|
957
|
+
H[0] = H[0] + a | 0;
|
|
958
|
+
H[1] = H[1] + b | 0;
|
|
959
|
+
H[2] = H[2] + c | 0;
|
|
960
|
+
H[3] = H[3] + d | 0;
|
|
961
|
+
H[4] = H[4] + e | 0;
|
|
962
|
+
},
|
|
963
|
+
_doFinalize: function() {
|
|
964
|
+
var data = this._data;
|
|
965
|
+
var dataWords = data.words;
|
|
966
|
+
var nBitsTotal = this._nDataBytes * 8;
|
|
967
|
+
var nBitsLeft = data.sigBytes * 8;
|
|
968
|
+
dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
|
|
969
|
+
dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = Math.floor(nBitsTotal / 4294967296);
|
|
970
|
+
dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = nBitsTotal;
|
|
971
|
+
data.sigBytes = dataWords.length * 4;
|
|
972
|
+
this._process();
|
|
973
|
+
return this._hash;
|
|
974
|
+
},
|
|
975
|
+
clone: function() {
|
|
976
|
+
var clone = Hasher.clone.call(this);
|
|
977
|
+
clone._hash = this._hash.clone();
|
|
978
|
+
return clone;
|
|
979
|
+
}
|
|
980
|
+
});
|
|
981
|
+
/**
|
|
982
|
+
* Shortcut function to the hasher's object interface.
|
|
983
|
+
*
|
|
984
|
+
* @param {WordArray|string} message The message to hash.
|
|
985
|
+
*
|
|
986
|
+
* @return {WordArray} The hash.
|
|
987
|
+
*
|
|
988
|
+
* @static
|
|
989
|
+
*
|
|
990
|
+
* @example
|
|
991
|
+
*
|
|
992
|
+
* var hash = CryptoJS.SHA1('message');
|
|
993
|
+
* var hash = CryptoJS.SHA1(wordArray);
|
|
994
|
+
*/
|
|
995
|
+
C.SHA1 = Hasher._createHelper(SHA1);
|
|
996
|
+
/**
|
|
997
|
+
* Shortcut function to the HMAC's object interface.
|
|
998
|
+
*
|
|
999
|
+
* @param {WordArray|string} message The message to hash.
|
|
1000
|
+
* @param {WordArray|string} key The secret key.
|
|
1001
|
+
*
|
|
1002
|
+
* @return {WordArray} The HMAC.
|
|
1003
|
+
*
|
|
1004
|
+
* @static
|
|
1005
|
+
*
|
|
1006
|
+
* @example
|
|
1007
|
+
*
|
|
1008
|
+
* var hmac = CryptoJS.HmacSHA1(message, key);
|
|
1009
|
+
*/
|
|
1010
|
+
C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
|
|
1011
|
+
})();
|
|
1012
|
+
return CryptoJS.SHA1;
|
|
1013
|
+
});
|
|
1014
|
+
}));
|
|
1015
|
+
//#endregion
|
|
1016
|
+
//#region node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/hmac.js
|
|
1017
|
+
var require_hmac = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1018
|
+
(function(root, factory) {
|
|
1019
|
+
if (typeof exports === "object") module.exports = exports = factory(require_core());
|
|
1020
|
+
else if (typeof define === "function" && define.amd) define(["./core"], factory);
|
|
1021
|
+
else factory(root.CryptoJS);
|
|
1022
|
+
})(exports, function(CryptoJS) {
|
|
1023
|
+
(function() {
|
|
1024
|
+
var C = CryptoJS;
|
|
1025
|
+
var Base = C.lib.Base;
|
|
1026
|
+
var Utf8 = C.enc.Utf8;
|
|
1027
|
+
var C_algo = C.algo;
|
|
1028
|
+
C_algo.HMAC = Base.extend({
|
|
1029
|
+
/**
|
|
1030
|
+
* Initializes a newly created HMAC.
|
|
1031
|
+
*
|
|
1032
|
+
* @param {Hasher} hasher The hash algorithm to use.
|
|
1033
|
+
* @param {WordArray|string} key The secret key.
|
|
1034
|
+
*
|
|
1035
|
+
* @example
|
|
1036
|
+
*
|
|
1037
|
+
* var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
|
|
1038
|
+
*/
|
|
1039
|
+
init: function(hasher, key) {
|
|
1040
|
+
hasher = this._hasher = new hasher.init();
|
|
1041
|
+
if (typeof key == "string") key = Utf8.parse(key);
|
|
1042
|
+
var hasherBlockSize = hasher.blockSize;
|
|
1043
|
+
var hasherBlockSizeBytes = hasherBlockSize * 4;
|
|
1044
|
+
if (key.sigBytes > hasherBlockSizeBytes) key = hasher.finalize(key);
|
|
1045
|
+
key.clamp();
|
|
1046
|
+
var oKey = this._oKey = key.clone();
|
|
1047
|
+
var iKey = this._iKey = key.clone();
|
|
1048
|
+
var oKeyWords = oKey.words;
|
|
1049
|
+
var iKeyWords = iKey.words;
|
|
1050
|
+
for (var i = 0; i < hasherBlockSize; i++) {
|
|
1051
|
+
oKeyWords[i] ^= 1549556828;
|
|
1052
|
+
iKeyWords[i] ^= 909522486;
|
|
1053
|
+
}
|
|
1054
|
+
oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
|
|
1055
|
+
this.reset();
|
|
1056
|
+
},
|
|
1057
|
+
/**
|
|
1058
|
+
* Resets this HMAC to its initial state.
|
|
1059
|
+
*
|
|
1060
|
+
* @example
|
|
1061
|
+
*
|
|
1062
|
+
* hmacHasher.reset();
|
|
1063
|
+
*/
|
|
1064
|
+
reset: function() {
|
|
1065
|
+
var hasher = this._hasher;
|
|
1066
|
+
hasher.reset();
|
|
1067
|
+
hasher.update(this._iKey);
|
|
1068
|
+
},
|
|
1069
|
+
/**
|
|
1070
|
+
* Updates this HMAC with a message.
|
|
1071
|
+
*
|
|
1072
|
+
* @param {WordArray|string} messageUpdate The message to append.
|
|
1073
|
+
*
|
|
1074
|
+
* @return {HMAC} This HMAC instance.
|
|
1075
|
+
*
|
|
1076
|
+
* @example
|
|
1077
|
+
*
|
|
1078
|
+
* hmacHasher.update('message');
|
|
1079
|
+
* hmacHasher.update(wordArray);
|
|
1080
|
+
*/
|
|
1081
|
+
update: function(messageUpdate) {
|
|
1082
|
+
this._hasher.update(messageUpdate);
|
|
1083
|
+
return this;
|
|
1084
|
+
},
|
|
1085
|
+
/**
|
|
1086
|
+
* Finalizes the HMAC computation.
|
|
1087
|
+
* Note that the finalize operation is effectively a destructive, read-once operation.
|
|
1088
|
+
*
|
|
1089
|
+
* @param {WordArray|string} messageUpdate (Optional) A final message update.
|
|
1090
|
+
*
|
|
1091
|
+
* @return {WordArray} The HMAC.
|
|
1092
|
+
*
|
|
1093
|
+
* @example
|
|
1094
|
+
*
|
|
1095
|
+
* var hmac = hmacHasher.finalize();
|
|
1096
|
+
* var hmac = hmacHasher.finalize('message');
|
|
1097
|
+
* var hmac = hmacHasher.finalize(wordArray);
|
|
1098
|
+
*/
|
|
1099
|
+
finalize: function(messageUpdate) {
|
|
1100
|
+
var hasher = this._hasher;
|
|
1101
|
+
var innerHash = hasher.finalize(messageUpdate);
|
|
1102
|
+
hasher.reset();
|
|
1103
|
+
return hasher.finalize(this._oKey.clone().concat(innerHash));
|
|
1104
|
+
}
|
|
1105
|
+
});
|
|
1106
|
+
})();
|
|
1107
|
+
});
|
|
1108
|
+
}));
|
|
1109
|
+
//#endregion
|
|
1110
|
+
//#region node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/evpkdf.js
|
|
1111
|
+
var require_evpkdf = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1112
|
+
(function(root, factory, undef) {
|
|
1113
|
+
if (typeof exports === "object") module.exports = exports = factory(require_core(), require_sha1(), require_hmac());
|
|
1114
|
+
else if (typeof define === "function" && define.amd) define([
|
|
1115
|
+
"./core",
|
|
1116
|
+
"./sha1",
|
|
1117
|
+
"./hmac"
|
|
1118
|
+
], factory);
|
|
1119
|
+
else factory(root.CryptoJS);
|
|
1120
|
+
})(exports, function(CryptoJS) {
|
|
1121
|
+
(function() {
|
|
1122
|
+
var C = CryptoJS;
|
|
1123
|
+
var C_lib = C.lib;
|
|
1124
|
+
var Base = C_lib.Base;
|
|
1125
|
+
var WordArray = C_lib.WordArray;
|
|
1126
|
+
var C_algo = C.algo;
|
|
1127
|
+
var MD5 = C_algo.MD5;
|
|
1128
|
+
/**
|
|
1129
|
+
* This key derivation function is meant to conform with EVP_BytesToKey.
|
|
1130
|
+
* www.openssl.org/docs/crypto/EVP_BytesToKey.html
|
|
1131
|
+
*/
|
|
1132
|
+
var EvpKDF = C_algo.EvpKDF = Base.extend({
|
|
1133
|
+
/**
|
|
1134
|
+
* Configuration options.
|
|
1135
|
+
*
|
|
1136
|
+
* @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
|
|
1137
|
+
* @property {Hasher} hasher The hash algorithm to use. Default: MD5
|
|
1138
|
+
* @property {number} iterations The number of iterations to perform. Default: 1
|
|
1139
|
+
*/
|
|
1140
|
+
cfg: Base.extend({
|
|
1141
|
+
keySize: 4,
|
|
1142
|
+
hasher: MD5,
|
|
1143
|
+
iterations: 1
|
|
1144
|
+
}),
|
|
1145
|
+
/**
|
|
1146
|
+
* Initializes a newly created key derivation function.
|
|
1147
|
+
*
|
|
1148
|
+
* @param {Object} cfg (Optional) The configuration options to use for the derivation.
|
|
1149
|
+
*
|
|
1150
|
+
* @example
|
|
1151
|
+
*
|
|
1152
|
+
* var kdf = CryptoJS.algo.EvpKDF.create();
|
|
1153
|
+
* var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
|
|
1154
|
+
* var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
|
|
1155
|
+
*/
|
|
1156
|
+
init: function(cfg) {
|
|
1157
|
+
this.cfg = this.cfg.extend(cfg);
|
|
1158
|
+
},
|
|
1159
|
+
/**
|
|
1160
|
+
* Derives a key from a password.
|
|
1161
|
+
*
|
|
1162
|
+
* @param {WordArray|string} password The password.
|
|
1163
|
+
* @param {WordArray|string} salt A salt.
|
|
1164
|
+
*
|
|
1165
|
+
* @return {WordArray} The derived key.
|
|
1166
|
+
*
|
|
1167
|
+
* @example
|
|
1168
|
+
*
|
|
1169
|
+
* var key = kdf.compute(password, salt);
|
|
1170
|
+
*/
|
|
1171
|
+
compute: function(password, salt) {
|
|
1172
|
+
var block;
|
|
1173
|
+
var cfg = this.cfg;
|
|
1174
|
+
var hasher = cfg.hasher.create();
|
|
1175
|
+
var derivedKey = WordArray.create();
|
|
1176
|
+
var derivedKeyWords = derivedKey.words;
|
|
1177
|
+
var keySize = cfg.keySize;
|
|
1178
|
+
var iterations = cfg.iterations;
|
|
1179
|
+
while (derivedKeyWords.length < keySize) {
|
|
1180
|
+
if (block) hasher.update(block);
|
|
1181
|
+
block = hasher.update(password).finalize(salt);
|
|
1182
|
+
hasher.reset();
|
|
1183
|
+
for (var i = 1; i < iterations; i++) {
|
|
1184
|
+
block = hasher.finalize(block);
|
|
1185
|
+
hasher.reset();
|
|
1186
|
+
}
|
|
1187
|
+
derivedKey.concat(block);
|
|
1188
|
+
}
|
|
1189
|
+
derivedKey.sigBytes = keySize * 4;
|
|
1190
|
+
return derivedKey;
|
|
1191
|
+
}
|
|
1192
|
+
});
|
|
1193
|
+
/**
|
|
1194
|
+
* Derives a key from a password.
|
|
1195
|
+
*
|
|
1196
|
+
* @param {WordArray|string} password The password.
|
|
1197
|
+
* @param {WordArray|string} salt A salt.
|
|
1198
|
+
* @param {Object} cfg (Optional) The configuration options to use for this computation.
|
|
1199
|
+
*
|
|
1200
|
+
* @return {WordArray} The derived key.
|
|
1201
|
+
*
|
|
1202
|
+
* @static
|
|
1203
|
+
*
|
|
1204
|
+
* @example
|
|
1205
|
+
*
|
|
1206
|
+
* var key = CryptoJS.EvpKDF(password, salt);
|
|
1207
|
+
* var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
|
|
1208
|
+
* var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
|
|
1209
|
+
*/
|
|
1210
|
+
C.EvpKDF = function(password, salt, cfg) {
|
|
1211
|
+
return EvpKDF.create(cfg).compute(password, salt);
|
|
1212
|
+
};
|
|
1213
|
+
})();
|
|
1214
|
+
return CryptoJS.EvpKDF;
|
|
1215
|
+
});
|
|
1216
|
+
}));
|
|
1217
|
+
//#endregion
|
|
1218
|
+
//#region node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/cipher-core.js
|
|
1219
|
+
var require_cipher_core = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1220
|
+
(function(root, factory, undef) {
|
|
1221
|
+
if (typeof exports === "object") module.exports = exports = factory(require_core(), require_evpkdf());
|
|
1222
|
+
else if (typeof define === "function" && define.amd) define(["./core", "./evpkdf"], factory);
|
|
1223
|
+
else factory(root.CryptoJS);
|
|
1224
|
+
})(exports, function(CryptoJS) {
|
|
1225
|
+
/**
|
|
1226
|
+
* Cipher core components.
|
|
1227
|
+
*/
|
|
1228
|
+
CryptoJS.lib.Cipher || function(undefined) {
|
|
1229
|
+
var C = CryptoJS;
|
|
1230
|
+
var C_lib = C.lib;
|
|
1231
|
+
var Base = C_lib.Base;
|
|
1232
|
+
var WordArray = C_lib.WordArray;
|
|
1233
|
+
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
|
|
1234
|
+
var C_enc = C.enc;
|
|
1235
|
+
C_enc.Utf8;
|
|
1236
|
+
var Base64 = C_enc.Base64;
|
|
1237
|
+
var EvpKDF = C.algo.EvpKDF;
|
|
1238
|
+
/**
|
|
1239
|
+
* Abstract base cipher template.
|
|
1240
|
+
*
|
|
1241
|
+
* @property {number} keySize This cipher's key size. Default: 4 (128 bits)
|
|
1242
|
+
* @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
|
|
1243
|
+
* @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
|
|
1244
|
+
* @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
|
|
1245
|
+
*/
|
|
1246
|
+
var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
|
|
1247
|
+
/**
|
|
1248
|
+
* Configuration options.
|
|
1249
|
+
*
|
|
1250
|
+
* @property {WordArray} iv The IV to use for this operation.
|
|
1251
|
+
*/
|
|
1252
|
+
cfg: Base.extend(),
|
|
1253
|
+
/**
|
|
1254
|
+
* Creates this cipher in encryption mode.
|
|
1255
|
+
*
|
|
1256
|
+
* @param {WordArray} key The key.
|
|
1257
|
+
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
1258
|
+
*
|
|
1259
|
+
* @return {Cipher} A cipher instance.
|
|
1260
|
+
*
|
|
1261
|
+
* @static
|
|
1262
|
+
*
|
|
1263
|
+
* @example
|
|
1264
|
+
*
|
|
1265
|
+
* var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
|
|
1266
|
+
*/
|
|
1267
|
+
createEncryptor: function(key, cfg) {
|
|
1268
|
+
return this.create(this._ENC_XFORM_MODE, key, cfg);
|
|
1269
|
+
},
|
|
1270
|
+
/**
|
|
1271
|
+
* Creates this cipher in decryption mode.
|
|
1272
|
+
*
|
|
1273
|
+
* @param {WordArray} key The key.
|
|
1274
|
+
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
1275
|
+
*
|
|
1276
|
+
* @return {Cipher} A cipher instance.
|
|
1277
|
+
*
|
|
1278
|
+
* @static
|
|
1279
|
+
*
|
|
1280
|
+
* @example
|
|
1281
|
+
*
|
|
1282
|
+
* var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
|
|
1283
|
+
*/
|
|
1284
|
+
createDecryptor: function(key, cfg) {
|
|
1285
|
+
return this.create(this._DEC_XFORM_MODE, key, cfg);
|
|
1286
|
+
},
|
|
1287
|
+
/**
|
|
1288
|
+
* Initializes a newly created cipher.
|
|
1289
|
+
*
|
|
1290
|
+
* @param {number} xformMode Either the encryption or decryption transormation mode constant.
|
|
1291
|
+
* @param {WordArray} key The key.
|
|
1292
|
+
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
1293
|
+
*
|
|
1294
|
+
* @example
|
|
1295
|
+
*
|
|
1296
|
+
* var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
|
|
1297
|
+
*/
|
|
1298
|
+
init: function(xformMode, key, cfg) {
|
|
1299
|
+
this.cfg = this.cfg.extend(cfg);
|
|
1300
|
+
this._xformMode = xformMode;
|
|
1301
|
+
this._key = key;
|
|
1302
|
+
this.reset();
|
|
1303
|
+
},
|
|
1304
|
+
/**
|
|
1305
|
+
* Resets this cipher to its initial state.
|
|
1306
|
+
*
|
|
1307
|
+
* @example
|
|
1308
|
+
*
|
|
1309
|
+
* cipher.reset();
|
|
1310
|
+
*/
|
|
1311
|
+
reset: function() {
|
|
1312
|
+
BufferedBlockAlgorithm.reset.call(this);
|
|
1313
|
+
this._doReset();
|
|
1314
|
+
},
|
|
1315
|
+
/**
|
|
1316
|
+
* Adds data to be encrypted or decrypted.
|
|
1317
|
+
*
|
|
1318
|
+
* @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
|
|
1319
|
+
*
|
|
1320
|
+
* @return {WordArray} The data after processing.
|
|
1321
|
+
*
|
|
1322
|
+
* @example
|
|
1323
|
+
*
|
|
1324
|
+
* var encrypted = cipher.process('data');
|
|
1325
|
+
* var encrypted = cipher.process(wordArray);
|
|
1326
|
+
*/
|
|
1327
|
+
process: function(dataUpdate) {
|
|
1328
|
+
this._append(dataUpdate);
|
|
1329
|
+
return this._process();
|
|
1330
|
+
},
|
|
1331
|
+
/**
|
|
1332
|
+
* Finalizes the encryption or decryption process.
|
|
1333
|
+
* Note that the finalize operation is effectively a destructive, read-once operation.
|
|
1334
|
+
*
|
|
1335
|
+
* @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
|
|
1336
|
+
*
|
|
1337
|
+
* @return {WordArray} The data after final processing.
|
|
1338
|
+
*
|
|
1339
|
+
* @example
|
|
1340
|
+
*
|
|
1341
|
+
* var encrypted = cipher.finalize();
|
|
1342
|
+
* var encrypted = cipher.finalize('data');
|
|
1343
|
+
* var encrypted = cipher.finalize(wordArray);
|
|
1344
|
+
*/
|
|
1345
|
+
finalize: function(dataUpdate) {
|
|
1346
|
+
if (dataUpdate) this._append(dataUpdate);
|
|
1347
|
+
return this._doFinalize();
|
|
1348
|
+
},
|
|
1349
|
+
keySize: 4,
|
|
1350
|
+
ivSize: 4,
|
|
1351
|
+
_ENC_XFORM_MODE: 1,
|
|
1352
|
+
_DEC_XFORM_MODE: 2,
|
|
1353
|
+
/**
|
|
1354
|
+
* Creates shortcut functions to a cipher's object interface.
|
|
1355
|
+
*
|
|
1356
|
+
* @param {Cipher} cipher The cipher to create a helper for.
|
|
1357
|
+
*
|
|
1358
|
+
* @return {Object} An object with encrypt and decrypt shortcut functions.
|
|
1359
|
+
*
|
|
1360
|
+
* @static
|
|
1361
|
+
*
|
|
1362
|
+
* @example
|
|
1363
|
+
*
|
|
1364
|
+
* var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
|
|
1365
|
+
*/
|
|
1366
|
+
_createHelper: function() {
|
|
1367
|
+
function selectCipherStrategy(key) {
|
|
1368
|
+
if (typeof key == "string") return PasswordBasedCipher;
|
|
1369
|
+
else return SerializableCipher;
|
|
1370
|
+
}
|
|
1371
|
+
return function(cipher) {
|
|
1372
|
+
return {
|
|
1373
|
+
encrypt: function(message, key, cfg) {
|
|
1374
|
+
return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
|
|
1375
|
+
},
|
|
1376
|
+
decrypt: function(ciphertext, key, cfg) {
|
|
1377
|
+
return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
|
|
1378
|
+
}
|
|
1379
|
+
};
|
|
1380
|
+
};
|
|
1381
|
+
}()
|
|
1382
|
+
});
|
|
1383
|
+
C_lib.StreamCipher = Cipher.extend({
|
|
1384
|
+
_doFinalize: function() {
|
|
1385
|
+
return this._process(true);
|
|
1386
|
+
},
|
|
1387
|
+
blockSize: 1
|
|
1388
|
+
});
|
|
1389
|
+
/**
|
|
1390
|
+
* Mode namespace.
|
|
1391
|
+
*/
|
|
1392
|
+
var C_mode = C.mode = {};
|
|
1393
|
+
/**
|
|
1394
|
+
* Abstract base block cipher mode template.
|
|
1395
|
+
*/
|
|
1396
|
+
var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
|
|
1397
|
+
/**
|
|
1398
|
+
* Creates this mode for encryption.
|
|
1399
|
+
*
|
|
1400
|
+
* @param {Cipher} cipher A block cipher instance.
|
|
1401
|
+
* @param {Array} iv The IV words.
|
|
1402
|
+
*
|
|
1403
|
+
* @static
|
|
1404
|
+
*
|
|
1405
|
+
* @example
|
|
1406
|
+
*
|
|
1407
|
+
* var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
|
|
1408
|
+
*/
|
|
1409
|
+
createEncryptor: function(cipher, iv) {
|
|
1410
|
+
return this.Encryptor.create(cipher, iv);
|
|
1411
|
+
},
|
|
1412
|
+
/**
|
|
1413
|
+
* Creates this mode for decryption.
|
|
1414
|
+
*
|
|
1415
|
+
* @param {Cipher} cipher A block cipher instance.
|
|
1416
|
+
* @param {Array} iv The IV words.
|
|
1417
|
+
*
|
|
1418
|
+
* @static
|
|
1419
|
+
*
|
|
1420
|
+
* @example
|
|
1421
|
+
*
|
|
1422
|
+
* var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
|
|
1423
|
+
*/
|
|
1424
|
+
createDecryptor: function(cipher, iv) {
|
|
1425
|
+
return this.Decryptor.create(cipher, iv);
|
|
1426
|
+
},
|
|
1427
|
+
/**
|
|
1428
|
+
* Initializes a newly created mode.
|
|
1429
|
+
*
|
|
1430
|
+
* @param {Cipher} cipher A block cipher instance.
|
|
1431
|
+
* @param {Array} iv The IV words.
|
|
1432
|
+
*
|
|
1433
|
+
* @example
|
|
1434
|
+
*
|
|
1435
|
+
* var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
|
|
1436
|
+
*/
|
|
1437
|
+
init: function(cipher, iv) {
|
|
1438
|
+
this._cipher = cipher;
|
|
1439
|
+
this._iv = iv;
|
|
1440
|
+
}
|
|
1441
|
+
});
|
|
1442
|
+
/**
|
|
1443
|
+
* Cipher Block Chaining mode.
|
|
1444
|
+
*/
|
|
1445
|
+
var CBC = C_mode.CBC = function() {
|
|
1446
|
+
/**
|
|
1447
|
+
* Abstract base CBC mode.
|
|
1448
|
+
*/
|
|
1449
|
+
var CBC = BlockCipherMode.extend();
|
|
1450
|
+
/**
|
|
1451
|
+
* CBC encryptor.
|
|
1452
|
+
*/
|
|
1453
|
+
CBC.Encryptor = CBC.extend({
|
|
1454
|
+
/**
|
|
1455
|
+
* Processes the data block at offset.
|
|
1456
|
+
*
|
|
1457
|
+
* @param {Array} words The data words to operate on.
|
|
1458
|
+
* @param {number} offset The offset where the block starts.
|
|
1459
|
+
*
|
|
1460
|
+
* @example
|
|
1461
|
+
*
|
|
1462
|
+
* mode.processBlock(data.words, offset);
|
|
1463
|
+
*/
|
|
1464
|
+
processBlock: function(words, offset) {
|
|
1465
|
+
var cipher = this._cipher;
|
|
1466
|
+
var blockSize = cipher.blockSize;
|
|
1467
|
+
xorBlock.call(this, words, offset, blockSize);
|
|
1468
|
+
cipher.encryptBlock(words, offset);
|
|
1469
|
+
this._prevBlock = words.slice(offset, offset + blockSize);
|
|
1470
|
+
} });
|
|
1471
|
+
/**
|
|
1472
|
+
* CBC decryptor.
|
|
1473
|
+
*/
|
|
1474
|
+
CBC.Decryptor = CBC.extend({
|
|
1475
|
+
/**
|
|
1476
|
+
* Processes the data block at offset.
|
|
1477
|
+
*
|
|
1478
|
+
* @param {Array} words The data words to operate on.
|
|
1479
|
+
* @param {number} offset The offset where the block starts.
|
|
1480
|
+
*
|
|
1481
|
+
* @example
|
|
1482
|
+
*
|
|
1483
|
+
* mode.processBlock(data.words, offset);
|
|
1484
|
+
*/
|
|
1485
|
+
processBlock: function(words, offset) {
|
|
1486
|
+
var cipher = this._cipher;
|
|
1487
|
+
var blockSize = cipher.blockSize;
|
|
1488
|
+
var thisBlock = words.slice(offset, offset + blockSize);
|
|
1489
|
+
cipher.decryptBlock(words, offset);
|
|
1490
|
+
xorBlock.call(this, words, offset, blockSize);
|
|
1491
|
+
this._prevBlock = thisBlock;
|
|
1492
|
+
} });
|
|
1493
|
+
function xorBlock(words, offset, blockSize) {
|
|
1494
|
+
var block;
|
|
1495
|
+
var iv = this._iv;
|
|
1496
|
+
if (iv) {
|
|
1497
|
+
block = iv;
|
|
1498
|
+
this._iv = undefined;
|
|
1499
|
+
} else block = this._prevBlock;
|
|
1500
|
+
for (var i = 0; i < blockSize; i++) words[offset + i] ^= block[i];
|
|
1501
|
+
}
|
|
1502
|
+
return CBC;
|
|
1503
|
+
}();
|
|
1504
|
+
/**
|
|
1505
|
+
* Padding namespace.
|
|
1506
|
+
*/
|
|
1507
|
+
var C_pad = C.pad = {};
|
|
1508
|
+
/**
|
|
1509
|
+
* PKCS #5/7 padding strategy.
|
|
1510
|
+
*/
|
|
1511
|
+
var Pkcs7 = C_pad.Pkcs7 = {
|
|
1512
|
+
/**
|
|
1513
|
+
* Pads data using the algorithm defined in PKCS #5/7.
|
|
1514
|
+
*
|
|
1515
|
+
* @param {WordArray} data The data to pad.
|
|
1516
|
+
* @param {number} blockSize The multiple that the data should be padded to.
|
|
1517
|
+
*
|
|
1518
|
+
* @static
|
|
1519
|
+
*
|
|
1520
|
+
* @example
|
|
1521
|
+
*
|
|
1522
|
+
* CryptoJS.pad.Pkcs7.pad(wordArray, 4);
|
|
1523
|
+
*/
|
|
1524
|
+
pad: function(data, blockSize) {
|
|
1525
|
+
var blockSizeBytes = blockSize * 4;
|
|
1526
|
+
var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
|
|
1527
|
+
var paddingWord = nPaddingBytes << 24 | nPaddingBytes << 16 | nPaddingBytes << 8 | nPaddingBytes;
|
|
1528
|
+
var paddingWords = [];
|
|
1529
|
+
for (var i = 0; i < nPaddingBytes; i += 4) paddingWords.push(paddingWord);
|
|
1530
|
+
var padding = WordArray.create(paddingWords, nPaddingBytes);
|
|
1531
|
+
data.concat(padding);
|
|
1532
|
+
},
|
|
1533
|
+
/**
|
|
1534
|
+
* Unpads data that had been padded using the algorithm defined in PKCS #5/7.
|
|
1535
|
+
*
|
|
1536
|
+
* @param {WordArray} data The data to unpad.
|
|
1537
|
+
*
|
|
1538
|
+
* @static
|
|
1539
|
+
*
|
|
1540
|
+
* @example
|
|
1541
|
+
*
|
|
1542
|
+
* CryptoJS.pad.Pkcs7.unpad(wordArray);
|
|
1543
|
+
*/
|
|
1544
|
+
unpad: function(data) {
|
|
1545
|
+
var nPaddingBytes = data.words[data.sigBytes - 1 >>> 2] & 255;
|
|
1546
|
+
data.sigBytes -= nPaddingBytes;
|
|
1547
|
+
}
|
|
1548
|
+
};
|
|
1549
|
+
C_lib.BlockCipher = Cipher.extend({
|
|
1550
|
+
/**
|
|
1551
|
+
* Configuration options.
|
|
1552
|
+
*
|
|
1553
|
+
* @property {Mode} mode The block mode to use. Default: CBC
|
|
1554
|
+
* @property {Padding} padding The padding strategy to use. Default: Pkcs7
|
|
1555
|
+
*/
|
|
1556
|
+
cfg: Cipher.cfg.extend({
|
|
1557
|
+
mode: CBC,
|
|
1558
|
+
padding: Pkcs7
|
|
1559
|
+
}),
|
|
1560
|
+
reset: function() {
|
|
1561
|
+
var modeCreator;
|
|
1562
|
+
Cipher.reset.call(this);
|
|
1563
|
+
var cfg = this.cfg;
|
|
1564
|
+
var iv = cfg.iv;
|
|
1565
|
+
var mode = cfg.mode;
|
|
1566
|
+
if (this._xformMode == this._ENC_XFORM_MODE) modeCreator = mode.createEncryptor;
|
|
1567
|
+
else {
|
|
1568
|
+
modeCreator = mode.createDecryptor;
|
|
1569
|
+
this._minBufferSize = 1;
|
|
1570
|
+
}
|
|
1571
|
+
if (this._mode && this._mode.__creator == modeCreator) this._mode.init(this, iv && iv.words);
|
|
1572
|
+
else {
|
|
1573
|
+
this._mode = modeCreator.call(mode, this, iv && iv.words);
|
|
1574
|
+
this._mode.__creator = modeCreator;
|
|
1575
|
+
}
|
|
1576
|
+
},
|
|
1577
|
+
_doProcessBlock: function(words, offset) {
|
|
1578
|
+
this._mode.processBlock(words, offset);
|
|
1579
|
+
},
|
|
1580
|
+
_doFinalize: function() {
|
|
1581
|
+
var finalProcessedBlocks;
|
|
1582
|
+
var padding = this.cfg.padding;
|
|
1583
|
+
if (this._xformMode == this._ENC_XFORM_MODE) {
|
|
1584
|
+
padding.pad(this._data, this.blockSize);
|
|
1585
|
+
finalProcessedBlocks = this._process(true);
|
|
1586
|
+
} else {
|
|
1587
|
+
finalProcessedBlocks = this._process(true);
|
|
1588
|
+
padding.unpad(finalProcessedBlocks);
|
|
1589
|
+
}
|
|
1590
|
+
return finalProcessedBlocks;
|
|
1591
|
+
},
|
|
1592
|
+
blockSize: 4
|
|
1593
|
+
});
|
|
1594
|
+
/**
|
|
1595
|
+
* A collection of cipher parameters.
|
|
1596
|
+
*
|
|
1597
|
+
* @property {WordArray} ciphertext The raw ciphertext.
|
|
1598
|
+
* @property {WordArray} key The key to this ciphertext.
|
|
1599
|
+
* @property {WordArray} iv The IV used in the ciphering operation.
|
|
1600
|
+
* @property {WordArray} salt The salt used with a key derivation function.
|
|
1601
|
+
* @property {Cipher} algorithm The cipher algorithm.
|
|
1602
|
+
* @property {Mode} mode The block mode used in the ciphering operation.
|
|
1603
|
+
* @property {Padding} padding The padding scheme used in the ciphering operation.
|
|
1604
|
+
* @property {number} blockSize The block size of the cipher.
|
|
1605
|
+
* @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
|
|
1606
|
+
*/
|
|
1607
|
+
var CipherParams = C_lib.CipherParams = Base.extend({
|
|
1608
|
+
/**
|
|
1609
|
+
* Initializes a newly created cipher params object.
|
|
1610
|
+
*
|
|
1611
|
+
* @param {Object} cipherParams An object with any of the possible cipher parameters.
|
|
1612
|
+
*
|
|
1613
|
+
* @example
|
|
1614
|
+
*
|
|
1615
|
+
* var cipherParams = CryptoJS.lib.CipherParams.create({
|
|
1616
|
+
* ciphertext: ciphertextWordArray,
|
|
1617
|
+
* key: keyWordArray,
|
|
1618
|
+
* iv: ivWordArray,
|
|
1619
|
+
* salt: saltWordArray,
|
|
1620
|
+
* algorithm: CryptoJS.algo.AES,
|
|
1621
|
+
* mode: CryptoJS.mode.CBC,
|
|
1622
|
+
* padding: CryptoJS.pad.PKCS7,
|
|
1623
|
+
* blockSize: 4,
|
|
1624
|
+
* formatter: CryptoJS.format.OpenSSL
|
|
1625
|
+
* });
|
|
1626
|
+
*/
|
|
1627
|
+
init: function(cipherParams) {
|
|
1628
|
+
this.mixIn(cipherParams);
|
|
1629
|
+
},
|
|
1630
|
+
/**
|
|
1631
|
+
* Converts this cipher params object to a string.
|
|
1632
|
+
*
|
|
1633
|
+
* @param {Format} formatter (Optional) The formatting strategy to use.
|
|
1634
|
+
*
|
|
1635
|
+
* @return {string} The stringified cipher params.
|
|
1636
|
+
*
|
|
1637
|
+
* @throws Error If neither the formatter nor the default formatter is set.
|
|
1638
|
+
*
|
|
1639
|
+
* @example
|
|
1640
|
+
*
|
|
1641
|
+
* var string = cipherParams + '';
|
|
1642
|
+
* var string = cipherParams.toString();
|
|
1643
|
+
* var string = cipherParams.toString(CryptoJS.format.OpenSSL);
|
|
1644
|
+
*/
|
|
1645
|
+
toString: function(formatter) {
|
|
1646
|
+
return (formatter || this.formatter).stringify(this);
|
|
1647
|
+
}
|
|
1648
|
+
});
|
|
1649
|
+
/**
|
|
1650
|
+
* Format namespace.
|
|
1651
|
+
*/
|
|
1652
|
+
var C_format = C.format = {};
|
|
1653
|
+
/**
|
|
1654
|
+
* OpenSSL formatting strategy.
|
|
1655
|
+
*/
|
|
1656
|
+
var OpenSSLFormatter = C_format.OpenSSL = {
|
|
1657
|
+
/**
|
|
1658
|
+
* Converts a cipher params object to an OpenSSL-compatible string.
|
|
1659
|
+
*
|
|
1660
|
+
* @param {CipherParams} cipherParams The cipher params object.
|
|
1661
|
+
*
|
|
1662
|
+
* @return {string} The OpenSSL-compatible string.
|
|
1663
|
+
*
|
|
1664
|
+
* @static
|
|
1665
|
+
*
|
|
1666
|
+
* @example
|
|
1667
|
+
*
|
|
1668
|
+
* var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
|
|
1669
|
+
*/
|
|
1670
|
+
stringify: function(cipherParams) {
|
|
1671
|
+
var wordArray;
|
|
1672
|
+
var ciphertext = cipherParams.ciphertext;
|
|
1673
|
+
var salt = cipherParams.salt;
|
|
1674
|
+
if (salt) wordArray = WordArray.create([1398893684, 1701076831]).concat(salt).concat(ciphertext);
|
|
1675
|
+
else wordArray = ciphertext;
|
|
1676
|
+
return wordArray.toString(Base64);
|
|
1677
|
+
},
|
|
1678
|
+
/**
|
|
1679
|
+
* Converts an OpenSSL-compatible string to a cipher params object.
|
|
1680
|
+
*
|
|
1681
|
+
* @param {string} openSSLStr The OpenSSL-compatible string.
|
|
1682
|
+
*
|
|
1683
|
+
* @return {CipherParams} The cipher params object.
|
|
1684
|
+
*
|
|
1685
|
+
* @static
|
|
1686
|
+
*
|
|
1687
|
+
* @example
|
|
1688
|
+
*
|
|
1689
|
+
* var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
|
|
1690
|
+
*/
|
|
1691
|
+
parse: function(openSSLStr) {
|
|
1692
|
+
var salt;
|
|
1693
|
+
var ciphertext = Base64.parse(openSSLStr);
|
|
1694
|
+
var ciphertextWords = ciphertext.words;
|
|
1695
|
+
if (ciphertextWords[0] == 1398893684 && ciphertextWords[1] == 1701076831) {
|
|
1696
|
+
salt = WordArray.create(ciphertextWords.slice(2, 4));
|
|
1697
|
+
ciphertextWords.splice(0, 4);
|
|
1698
|
+
ciphertext.sigBytes -= 16;
|
|
1699
|
+
}
|
|
1700
|
+
return CipherParams.create({
|
|
1701
|
+
ciphertext,
|
|
1702
|
+
salt
|
|
1703
|
+
});
|
|
1704
|
+
}
|
|
1705
|
+
};
|
|
1706
|
+
/**
|
|
1707
|
+
* A cipher wrapper that returns ciphertext as a serializable cipher params object.
|
|
1708
|
+
*/
|
|
1709
|
+
var SerializableCipher = C_lib.SerializableCipher = Base.extend({
|
|
1710
|
+
/**
|
|
1711
|
+
* Configuration options.
|
|
1712
|
+
*
|
|
1713
|
+
* @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
|
|
1714
|
+
*/
|
|
1715
|
+
cfg: Base.extend({ format: OpenSSLFormatter }),
|
|
1716
|
+
/**
|
|
1717
|
+
* Encrypts a message.
|
|
1718
|
+
*
|
|
1719
|
+
* @param {Cipher} cipher The cipher algorithm to use.
|
|
1720
|
+
* @param {WordArray|string} message The message to encrypt.
|
|
1721
|
+
* @param {WordArray} key The key.
|
|
1722
|
+
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
1723
|
+
*
|
|
1724
|
+
* @return {CipherParams} A cipher params object.
|
|
1725
|
+
*
|
|
1726
|
+
* @static
|
|
1727
|
+
*
|
|
1728
|
+
* @example
|
|
1729
|
+
*
|
|
1730
|
+
* var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
|
|
1731
|
+
* var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
|
|
1732
|
+
* var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
|
|
1733
|
+
*/
|
|
1734
|
+
encrypt: function(cipher, message, key, cfg) {
|
|
1735
|
+
cfg = this.cfg.extend(cfg);
|
|
1736
|
+
var encryptor = cipher.createEncryptor(key, cfg);
|
|
1737
|
+
var ciphertext = encryptor.finalize(message);
|
|
1738
|
+
var cipherCfg = encryptor.cfg;
|
|
1739
|
+
return CipherParams.create({
|
|
1740
|
+
ciphertext,
|
|
1741
|
+
key,
|
|
1742
|
+
iv: cipherCfg.iv,
|
|
1743
|
+
algorithm: cipher,
|
|
1744
|
+
mode: cipherCfg.mode,
|
|
1745
|
+
padding: cipherCfg.padding,
|
|
1746
|
+
blockSize: cipher.blockSize,
|
|
1747
|
+
formatter: cfg.format
|
|
1748
|
+
});
|
|
1749
|
+
},
|
|
1750
|
+
/**
|
|
1751
|
+
* Decrypts serialized ciphertext.
|
|
1752
|
+
*
|
|
1753
|
+
* @param {Cipher} cipher The cipher algorithm to use.
|
|
1754
|
+
* @param {CipherParams|string} ciphertext The ciphertext to decrypt.
|
|
1755
|
+
* @param {WordArray} key The key.
|
|
1756
|
+
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
1757
|
+
*
|
|
1758
|
+
* @return {WordArray} The plaintext.
|
|
1759
|
+
*
|
|
1760
|
+
* @static
|
|
1761
|
+
*
|
|
1762
|
+
* @example
|
|
1763
|
+
*
|
|
1764
|
+
* var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
|
|
1765
|
+
* var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
|
|
1766
|
+
*/
|
|
1767
|
+
decrypt: function(cipher, ciphertext, key, cfg) {
|
|
1768
|
+
cfg = this.cfg.extend(cfg);
|
|
1769
|
+
ciphertext = this._parse(ciphertext, cfg.format);
|
|
1770
|
+
return cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
|
|
1771
|
+
},
|
|
1772
|
+
/**
|
|
1773
|
+
* Converts serialized ciphertext to CipherParams,
|
|
1774
|
+
* else assumed CipherParams already and returns ciphertext unchanged.
|
|
1775
|
+
*
|
|
1776
|
+
* @param {CipherParams|string} ciphertext The ciphertext.
|
|
1777
|
+
* @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
|
|
1778
|
+
*
|
|
1779
|
+
* @return {CipherParams} The unserialized ciphertext.
|
|
1780
|
+
*
|
|
1781
|
+
* @static
|
|
1782
|
+
*
|
|
1783
|
+
* @example
|
|
1784
|
+
*
|
|
1785
|
+
* var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
|
|
1786
|
+
*/
|
|
1787
|
+
_parse: function(ciphertext, format) {
|
|
1788
|
+
if (typeof ciphertext == "string") return format.parse(ciphertext, this);
|
|
1789
|
+
else return ciphertext;
|
|
1790
|
+
}
|
|
1791
|
+
});
|
|
1792
|
+
/**
|
|
1793
|
+
* Key derivation function namespace.
|
|
1794
|
+
*/
|
|
1795
|
+
var C_kdf = C.kdf = {};
|
|
1796
|
+
/**
|
|
1797
|
+
* OpenSSL key derivation function.
|
|
1798
|
+
*/
|
|
1799
|
+
var OpenSSLKdf = C_kdf.OpenSSL = {
|
|
1800
|
+
/**
|
|
1801
|
+
* Derives a key and IV from a password.
|
|
1802
|
+
*
|
|
1803
|
+
* @param {string} password The password to derive from.
|
|
1804
|
+
* @param {number} keySize The size in words of the key to generate.
|
|
1805
|
+
* @param {number} ivSize The size in words of the IV to generate.
|
|
1806
|
+
* @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
|
|
1807
|
+
*
|
|
1808
|
+
* @return {CipherParams} A cipher params object with the key, IV, and salt.
|
|
1809
|
+
*
|
|
1810
|
+
* @static
|
|
1811
|
+
*
|
|
1812
|
+
* @example
|
|
1813
|
+
*
|
|
1814
|
+
* var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
|
|
1815
|
+
* var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
|
|
1816
|
+
*/
|
|
1817
|
+
execute: function(password, keySize, ivSize, salt, hasher) {
|
|
1818
|
+
if (!salt) salt = WordArray.random(8);
|
|
1819
|
+
if (!hasher) var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
|
|
1820
|
+
else var key = EvpKDF.create({
|
|
1821
|
+
keySize: keySize + ivSize,
|
|
1822
|
+
hasher
|
|
1823
|
+
}).compute(password, salt);
|
|
1824
|
+
var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
|
|
1825
|
+
key.sigBytes = keySize * 4;
|
|
1826
|
+
return CipherParams.create({
|
|
1827
|
+
key,
|
|
1828
|
+
iv,
|
|
1829
|
+
salt
|
|
1830
|
+
});
|
|
1831
|
+
} };
|
|
1832
|
+
/**
|
|
1833
|
+
* A serializable cipher wrapper that derives the key from a password,
|
|
1834
|
+
* and returns ciphertext as a serializable cipher params object.
|
|
1835
|
+
*/
|
|
1836
|
+
var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
|
|
1837
|
+
/**
|
|
1838
|
+
* Configuration options.
|
|
1839
|
+
*
|
|
1840
|
+
* @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
|
|
1841
|
+
*/
|
|
1842
|
+
cfg: SerializableCipher.cfg.extend({ kdf: OpenSSLKdf }),
|
|
1843
|
+
/**
|
|
1844
|
+
* Encrypts a message using a password.
|
|
1845
|
+
*
|
|
1846
|
+
* @param {Cipher} cipher The cipher algorithm to use.
|
|
1847
|
+
* @param {WordArray|string} message The message to encrypt.
|
|
1848
|
+
* @param {string} password The password.
|
|
1849
|
+
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
1850
|
+
*
|
|
1851
|
+
* @return {CipherParams} A cipher params object.
|
|
1852
|
+
*
|
|
1853
|
+
* @static
|
|
1854
|
+
*
|
|
1855
|
+
* @example
|
|
1856
|
+
*
|
|
1857
|
+
* var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
|
|
1858
|
+
* var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
|
|
1859
|
+
*/
|
|
1860
|
+
encrypt: function(cipher, message, password, cfg) {
|
|
1861
|
+
cfg = this.cfg.extend(cfg);
|
|
1862
|
+
var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, cfg.salt, cfg.hasher);
|
|
1863
|
+
cfg.iv = derivedParams.iv;
|
|
1864
|
+
var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
|
|
1865
|
+
ciphertext.mixIn(derivedParams);
|
|
1866
|
+
return ciphertext;
|
|
1867
|
+
},
|
|
1868
|
+
/**
|
|
1869
|
+
* Decrypts serialized ciphertext using a password.
|
|
1870
|
+
*
|
|
1871
|
+
* @param {Cipher} cipher The cipher algorithm to use.
|
|
1872
|
+
* @param {CipherParams|string} ciphertext The ciphertext to decrypt.
|
|
1873
|
+
* @param {string} password The password.
|
|
1874
|
+
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
|
1875
|
+
*
|
|
1876
|
+
* @return {WordArray} The plaintext.
|
|
1877
|
+
*
|
|
1878
|
+
* @static
|
|
1879
|
+
*
|
|
1880
|
+
* @example
|
|
1881
|
+
*
|
|
1882
|
+
* var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
|
|
1883
|
+
* var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
|
|
1884
|
+
*/
|
|
1885
|
+
decrypt: function(cipher, ciphertext, password, cfg) {
|
|
1886
|
+
cfg = this.cfg.extend(cfg);
|
|
1887
|
+
ciphertext = this._parse(ciphertext, cfg.format);
|
|
1888
|
+
var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt, cfg.hasher);
|
|
1889
|
+
cfg.iv = derivedParams.iv;
|
|
1890
|
+
return SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
|
|
1891
|
+
}
|
|
1892
|
+
});
|
|
1893
|
+
}();
|
|
1894
|
+
});
|
|
1895
|
+
}));
|
|
1896
|
+
//#endregion
|
|
1897
|
+
//#region node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js
|
|
1898
|
+
var require_aes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1899
|
+
(function(root, factory, undef) {
|
|
1900
|
+
if (typeof exports === "object") module.exports = exports = factory(require_core(), require_enc_base64(), require_md5(), require_evpkdf(), require_cipher_core());
|
|
1901
|
+
else if (typeof define === "function" && define.amd) define([
|
|
1902
|
+
"./core",
|
|
1903
|
+
"./enc-base64",
|
|
1904
|
+
"./md5",
|
|
1905
|
+
"./evpkdf",
|
|
1906
|
+
"./cipher-core"
|
|
1907
|
+
], factory);
|
|
1908
|
+
else factory(root.CryptoJS);
|
|
1909
|
+
})(exports, function(CryptoJS) {
|
|
1910
|
+
(function() {
|
|
1911
|
+
var C = CryptoJS;
|
|
1912
|
+
var BlockCipher = C.lib.BlockCipher;
|
|
1913
|
+
var C_algo = C.algo;
|
|
1914
|
+
var SBOX = [];
|
|
1915
|
+
var INV_SBOX = [];
|
|
1916
|
+
var SUB_MIX_0 = [];
|
|
1917
|
+
var SUB_MIX_1 = [];
|
|
1918
|
+
var SUB_MIX_2 = [];
|
|
1919
|
+
var SUB_MIX_3 = [];
|
|
1920
|
+
var INV_SUB_MIX_0 = [];
|
|
1921
|
+
var INV_SUB_MIX_1 = [];
|
|
1922
|
+
var INV_SUB_MIX_2 = [];
|
|
1923
|
+
var INV_SUB_MIX_3 = [];
|
|
1924
|
+
(function() {
|
|
1925
|
+
var d = [];
|
|
1926
|
+
for (var i = 0; i < 256; i++) if (i < 128) d[i] = i << 1;
|
|
1927
|
+
else d[i] = i << 1 ^ 283;
|
|
1928
|
+
var x = 0;
|
|
1929
|
+
var xi = 0;
|
|
1930
|
+
for (var i = 0; i < 256; i++) {
|
|
1931
|
+
var sx = xi ^ xi << 1 ^ xi << 2 ^ xi << 3 ^ xi << 4;
|
|
1932
|
+
sx = sx >>> 8 ^ sx & 255 ^ 99;
|
|
1933
|
+
SBOX[x] = sx;
|
|
1934
|
+
INV_SBOX[sx] = x;
|
|
1935
|
+
var x2 = d[x];
|
|
1936
|
+
var x4 = d[x2];
|
|
1937
|
+
var x8 = d[x4];
|
|
1938
|
+
var t = d[sx] * 257 ^ sx * 16843008;
|
|
1939
|
+
SUB_MIX_0[x] = t << 24 | t >>> 8;
|
|
1940
|
+
SUB_MIX_1[x] = t << 16 | t >>> 16;
|
|
1941
|
+
SUB_MIX_2[x] = t << 8 | t >>> 24;
|
|
1942
|
+
SUB_MIX_3[x] = t;
|
|
1943
|
+
var t = x8 * 16843009 ^ x4 * 65537 ^ x2 * 257 ^ x * 16843008;
|
|
1944
|
+
INV_SUB_MIX_0[sx] = t << 24 | t >>> 8;
|
|
1945
|
+
INV_SUB_MIX_1[sx] = t << 16 | t >>> 16;
|
|
1946
|
+
INV_SUB_MIX_2[sx] = t << 8 | t >>> 24;
|
|
1947
|
+
INV_SUB_MIX_3[sx] = t;
|
|
1948
|
+
if (!x) x = xi = 1;
|
|
1949
|
+
else {
|
|
1950
|
+
x = x2 ^ d[d[d[x8 ^ x2]]];
|
|
1951
|
+
xi ^= d[d[xi]];
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
})();
|
|
1955
|
+
var RCON = [
|
|
1956
|
+
0,
|
|
1957
|
+
1,
|
|
1958
|
+
2,
|
|
1959
|
+
4,
|
|
1960
|
+
8,
|
|
1961
|
+
16,
|
|
1962
|
+
32,
|
|
1963
|
+
64,
|
|
1964
|
+
128,
|
|
1965
|
+
27,
|
|
1966
|
+
54
|
|
1967
|
+
];
|
|
1968
|
+
/**
|
|
1969
|
+
* AES block cipher algorithm.
|
|
1970
|
+
*/
|
|
1971
|
+
var AES = C_algo.AES = BlockCipher.extend({
|
|
1972
|
+
_doReset: function() {
|
|
1973
|
+
var t;
|
|
1974
|
+
if (this._nRounds && this._keyPriorReset === this._key) return;
|
|
1975
|
+
var key = this._keyPriorReset = this._key;
|
|
1976
|
+
var keyWords = key.words;
|
|
1977
|
+
var keySize = key.sigBytes / 4;
|
|
1978
|
+
var ksRows = ((this._nRounds = keySize + 6) + 1) * 4;
|
|
1979
|
+
var keySchedule = this._keySchedule = [];
|
|
1980
|
+
for (var ksRow = 0; ksRow < ksRows; ksRow++) if (ksRow < keySize) keySchedule[ksRow] = keyWords[ksRow];
|
|
1981
|
+
else {
|
|
1982
|
+
t = keySchedule[ksRow - 1];
|
|
1983
|
+
if (!(ksRow % keySize)) {
|
|
1984
|
+
t = t << 8 | t >>> 24;
|
|
1985
|
+
t = SBOX[t >>> 24] << 24 | SBOX[t >>> 16 & 255] << 16 | SBOX[t >>> 8 & 255] << 8 | SBOX[t & 255];
|
|
1986
|
+
t ^= RCON[ksRow / keySize | 0] << 24;
|
|
1987
|
+
} else if (keySize > 6 && ksRow % keySize == 4) t = SBOX[t >>> 24] << 24 | SBOX[t >>> 16 & 255] << 16 | SBOX[t >>> 8 & 255] << 8 | SBOX[t & 255];
|
|
1988
|
+
keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
|
|
1989
|
+
}
|
|
1990
|
+
var invKeySchedule = this._invKeySchedule = [];
|
|
1991
|
+
for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
|
|
1992
|
+
var ksRow = ksRows - invKsRow;
|
|
1993
|
+
if (invKsRow % 4) var t = keySchedule[ksRow];
|
|
1994
|
+
else var t = keySchedule[ksRow - 4];
|
|
1995
|
+
if (invKsRow < 4 || ksRow <= 4) invKeySchedule[invKsRow] = t;
|
|
1996
|
+
else 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]];
|
|
1997
|
+
}
|
|
1998
|
+
},
|
|
1999
|
+
encryptBlock: function(M, offset) {
|
|
2000
|
+
this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
|
|
2001
|
+
},
|
|
2002
|
+
decryptBlock: function(M, offset) {
|
|
2003
|
+
var t = M[offset + 1];
|
|
2004
|
+
M[offset + 1] = M[offset + 3];
|
|
2005
|
+
M[offset + 3] = t;
|
|
2006
|
+
this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
|
|
2007
|
+
var t = M[offset + 1];
|
|
2008
|
+
M[offset + 1] = M[offset + 3];
|
|
2009
|
+
M[offset + 3] = t;
|
|
2010
|
+
},
|
|
2011
|
+
_doCryptBlock: function(M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
|
|
2012
|
+
var nRounds = this._nRounds;
|
|
2013
|
+
var s0 = M[offset] ^ keySchedule[0];
|
|
2014
|
+
var s1 = M[offset + 1] ^ keySchedule[1];
|
|
2015
|
+
var s2 = M[offset + 2] ^ keySchedule[2];
|
|
2016
|
+
var s3 = M[offset + 3] ^ keySchedule[3];
|
|
2017
|
+
var ksRow = 4;
|
|
2018
|
+
for (var round = 1; round < nRounds; round++) {
|
|
2019
|
+
var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[s1 >>> 16 & 255] ^ SUB_MIX_2[s2 >>> 8 & 255] ^ SUB_MIX_3[s3 & 255] ^ keySchedule[ksRow++];
|
|
2020
|
+
var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[s2 >>> 16 & 255] ^ SUB_MIX_2[s3 >>> 8 & 255] ^ SUB_MIX_3[s0 & 255] ^ keySchedule[ksRow++];
|
|
2021
|
+
var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[s3 >>> 16 & 255] ^ SUB_MIX_2[s0 >>> 8 & 255] ^ SUB_MIX_3[s1 & 255] ^ keySchedule[ksRow++];
|
|
2022
|
+
var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[s0 >>> 16 & 255] ^ SUB_MIX_2[s1 >>> 8 & 255] ^ SUB_MIX_3[s2 & 255] ^ keySchedule[ksRow++];
|
|
2023
|
+
s0 = t0;
|
|
2024
|
+
s1 = t1;
|
|
2025
|
+
s2 = t2;
|
|
2026
|
+
s3 = t3;
|
|
2027
|
+
}
|
|
2028
|
+
var t0 = (SBOX[s0 >>> 24] << 24 | SBOX[s1 >>> 16 & 255] << 16 | SBOX[s2 >>> 8 & 255] << 8 | SBOX[s3 & 255]) ^ keySchedule[ksRow++];
|
|
2029
|
+
var t1 = (SBOX[s1 >>> 24] << 24 | SBOX[s2 >>> 16 & 255] << 16 | SBOX[s3 >>> 8 & 255] << 8 | SBOX[s0 & 255]) ^ keySchedule[ksRow++];
|
|
2030
|
+
var t2 = (SBOX[s2 >>> 24] << 24 | SBOX[s3 >>> 16 & 255] << 16 | SBOX[s0 >>> 8 & 255] << 8 | SBOX[s1 & 255]) ^ keySchedule[ksRow++];
|
|
2031
|
+
var t3 = (SBOX[s3 >>> 24] << 24 | SBOX[s0 >>> 16 & 255] << 16 | SBOX[s1 >>> 8 & 255] << 8 | SBOX[s2 & 255]) ^ keySchedule[ksRow++];
|
|
2032
|
+
M[offset] = t0;
|
|
2033
|
+
M[offset + 1] = t1;
|
|
2034
|
+
M[offset + 2] = t2;
|
|
2035
|
+
M[offset + 3] = t3;
|
|
2036
|
+
},
|
|
2037
|
+
keySize: 8
|
|
2038
|
+
});
|
|
2039
|
+
/**
|
|
2040
|
+
* Shortcut functions to the cipher's object interface.
|
|
2041
|
+
*
|
|
2042
|
+
* @example
|
|
2043
|
+
*
|
|
2044
|
+
* var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
|
|
2045
|
+
* var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
|
|
2046
|
+
*/
|
|
2047
|
+
C.AES = BlockCipher._createHelper(AES);
|
|
2048
|
+
})();
|
|
2049
|
+
return CryptoJS.AES;
|
|
2050
|
+
});
|
|
2051
|
+
}));
|
|
2052
|
+
//#endregion
|
|
2053
|
+
//#region node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-hex.js
|
|
2054
|
+
var require_enc_hex = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2055
|
+
(function(root, factory) {
|
|
2056
|
+
if (typeof exports === "object") module.exports = exports = factory(require_core());
|
|
2057
|
+
else if (typeof define === "function" && define.amd) define(["./core"], factory);
|
|
2058
|
+
else factory(root.CryptoJS);
|
|
2059
|
+
})(exports, function(CryptoJS) {
|
|
2060
|
+
return CryptoJS.enc.Hex;
|
|
2061
|
+
});
|
|
2062
|
+
}));
|
|
2063
|
+
//#endregion
|
|
2064
|
+
//#region node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js
|
|
2065
|
+
var require_enc_utf8 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2066
|
+
(function(root, factory) {
|
|
2067
|
+
if (typeof exports === "object") module.exports = exports = factory(require_core());
|
|
2068
|
+
else if (typeof define === "function" && define.amd) define(["./core"], factory);
|
|
2069
|
+
else factory(root.CryptoJS);
|
|
2070
|
+
})(exports, function(CryptoJS) {
|
|
2071
|
+
return CryptoJS.enc.Utf8;
|
|
2072
|
+
});
|
|
2073
|
+
}));
|
|
2074
|
+
//#endregion
|
|
2075
|
+
//#region node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js
|
|
2076
|
+
var require_mode_ecb = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2077
|
+
(function(root, factory, undef) {
|
|
2078
|
+
if (typeof exports === "object") module.exports = exports = factory(require_core(), require_cipher_core());
|
|
2079
|
+
else if (typeof define === "function" && define.amd) define(["./core", "./cipher-core"], factory);
|
|
2080
|
+
else factory(root.CryptoJS);
|
|
2081
|
+
})(exports, function(CryptoJS) {
|
|
2082
|
+
/**
|
|
2083
|
+
* Electronic Codebook block mode.
|
|
2084
|
+
*/
|
|
2085
|
+
CryptoJS.mode.ECB = function() {
|
|
2086
|
+
var ECB = CryptoJS.lib.BlockCipherMode.extend();
|
|
2087
|
+
ECB.Encryptor = ECB.extend({ processBlock: function(words, offset) {
|
|
2088
|
+
this._cipher.encryptBlock(words, offset);
|
|
2089
|
+
} });
|
|
2090
|
+
ECB.Decryptor = ECB.extend({ processBlock: function(words, offset) {
|
|
2091
|
+
this._cipher.decryptBlock(words, offset);
|
|
2092
|
+
} });
|
|
2093
|
+
return ECB;
|
|
2094
|
+
}();
|
|
2095
|
+
return CryptoJS.mode.ECB;
|
|
2096
|
+
});
|
|
2097
|
+
}));
|
|
2098
|
+
//#endregion
|
|
2099
|
+
//#region node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-ansix923.js
|
|
2100
|
+
var require_pad_ansix923 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2101
|
+
(function(root, factory, undef) {
|
|
2102
|
+
if (typeof exports === "object") module.exports = exports = factory(require_core(), require_cipher_core());
|
|
2103
|
+
else if (typeof define === "function" && define.amd) define(["./core", "./cipher-core"], factory);
|
|
2104
|
+
else factory(root.CryptoJS);
|
|
2105
|
+
})(exports, function(CryptoJS) {
|
|
2106
|
+
/**
|
|
2107
|
+
* ANSI X.923 padding strategy.
|
|
2108
|
+
*/
|
|
2109
|
+
CryptoJS.pad.AnsiX923 = {
|
|
2110
|
+
pad: function(data, blockSize) {
|
|
2111
|
+
var dataSigBytes = data.sigBytes;
|
|
2112
|
+
var blockSizeBytes = blockSize * 4;
|
|
2113
|
+
var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
|
|
2114
|
+
var lastBytePos = dataSigBytes + nPaddingBytes - 1;
|
|
2115
|
+
data.clamp();
|
|
2116
|
+
data.words[lastBytePos >>> 2] |= nPaddingBytes << 24 - lastBytePos % 4 * 8;
|
|
2117
|
+
data.sigBytes += nPaddingBytes;
|
|
2118
|
+
},
|
|
2119
|
+
unpad: function(data) {
|
|
2120
|
+
var nPaddingBytes = data.words[data.sigBytes - 1 >>> 2] & 255;
|
|
2121
|
+
data.sigBytes -= nPaddingBytes;
|
|
2122
|
+
}
|
|
2123
|
+
};
|
|
2124
|
+
return CryptoJS.pad.Ansix923;
|
|
2125
|
+
});
|
|
2126
|
+
}));
|
|
2127
|
+
//#endregion
|
|
2128
|
+
//#region node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-iso10126.js
|
|
2129
|
+
var require_pad_iso10126 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2130
|
+
(function(root, factory, undef) {
|
|
2131
|
+
if (typeof exports === "object") module.exports = exports = factory(require_core(), require_cipher_core());
|
|
2132
|
+
else if (typeof define === "function" && define.amd) define(["./core", "./cipher-core"], factory);
|
|
2133
|
+
else factory(root.CryptoJS);
|
|
2134
|
+
})(exports, function(CryptoJS) {
|
|
2135
|
+
/**
|
|
2136
|
+
* ISO 10126 padding strategy.
|
|
2137
|
+
*/
|
|
2138
|
+
CryptoJS.pad.Iso10126 = {
|
|
2139
|
+
pad: function(data, blockSize) {
|
|
2140
|
+
var blockSizeBytes = blockSize * 4;
|
|
2141
|
+
var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
|
|
2142
|
+
data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
|
|
2143
|
+
},
|
|
2144
|
+
unpad: function(data) {
|
|
2145
|
+
var nPaddingBytes = data.words[data.sigBytes - 1 >>> 2] & 255;
|
|
2146
|
+
data.sigBytes -= nPaddingBytes;
|
|
2147
|
+
}
|
|
2148
|
+
};
|
|
2149
|
+
return CryptoJS.pad.Iso10126;
|
|
2150
|
+
});
|
|
2151
|
+
}));
|
|
2152
|
+
//#endregion
|
|
2153
|
+
//#region node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-nopadding.js
|
|
2154
|
+
var require_pad_nopadding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2155
|
+
(function(root, factory, undef) {
|
|
2156
|
+
if (typeof exports === "object") module.exports = exports = factory(require_core(), require_cipher_core());
|
|
2157
|
+
else if (typeof define === "function" && define.amd) define(["./core", "./cipher-core"], factory);
|
|
2158
|
+
else factory(root.CryptoJS);
|
|
2159
|
+
})(exports, function(CryptoJS) {
|
|
2160
|
+
/**
|
|
2161
|
+
* A noop padding strategy.
|
|
2162
|
+
*/
|
|
2163
|
+
CryptoJS.pad.NoPadding = {
|
|
2164
|
+
pad: function() {},
|
|
2165
|
+
unpad: function() {}
|
|
2166
|
+
};
|
|
2167
|
+
return CryptoJS.pad.NoPadding;
|
|
2168
|
+
});
|
|
2169
|
+
}));
|
|
2170
|
+
//#endregion
|
|
2171
|
+
//#region node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-pkcs7.js
|
|
2172
|
+
var require_pad_pkcs7 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2173
|
+
(function(root, factory, undef) {
|
|
2174
|
+
if (typeof exports === "object") module.exports = exports = factory(require_core(), require_cipher_core());
|
|
2175
|
+
else if (typeof define === "function" && define.amd) define(["./core", "./cipher-core"], factory);
|
|
2176
|
+
else factory(root.CryptoJS);
|
|
2177
|
+
})(exports, function(CryptoJS) {
|
|
2178
|
+
return CryptoJS.pad.Pkcs7;
|
|
2179
|
+
});
|
|
2180
|
+
}));
|
|
2181
|
+
//#endregion
|
|
2182
|
+
//#region node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-zeropadding.js
|
|
2183
|
+
var require_pad_zeropadding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2184
|
+
(function(root, factory, undef) {
|
|
2185
|
+
if (typeof exports === "object") module.exports = exports = factory(require_core(), require_cipher_core());
|
|
2186
|
+
else if (typeof define === "function" && define.amd) define(["./core", "./cipher-core"], factory);
|
|
2187
|
+
else factory(root.CryptoJS);
|
|
2188
|
+
})(exports, function(CryptoJS) {
|
|
2189
|
+
/**
|
|
2190
|
+
* Zero padding strategy.
|
|
2191
|
+
*/
|
|
2192
|
+
CryptoJS.pad.ZeroPadding = {
|
|
2193
|
+
pad: function(data, blockSize) {
|
|
2194
|
+
var blockSizeBytes = blockSize * 4;
|
|
2195
|
+
data.clamp();
|
|
2196
|
+
data.sigBytes += blockSizeBytes - (data.sigBytes % blockSizeBytes || blockSizeBytes);
|
|
2197
|
+
},
|
|
2198
|
+
unpad: function(data) {
|
|
2199
|
+
var dataWords = data.words;
|
|
2200
|
+
var i = data.sigBytes - 1;
|
|
2201
|
+
for (var i = data.sigBytes - 1; i >= 0; i--) if (dataWords[i >>> 2] >>> 24 - i % 4 * 8 & 255) {
|
|
2202
|
+
data.sigBytes = i + 1;
|
|
2203
|
+
break;
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
};
|
|
2207
|
+
return CryptoJS.pad.ZeroPadding;
|
|
2208
|
+
});
|
|
2209
|
+
}));
|
|
2210
|
+
//#endregion
|
|
16
2211
|
//#region src/crypto/index.ts
|
|
2212
|
+
var import_aes = /* @__PURE__ */ __toESM(require_aes(), 1);
|
|
2213
|
+
var import_core = /* @__PURE__ */ __toESM(require_core(), 1);
|
|
2214
|
+
var import_enc_hex = /* @__PURE__ */ __toESM(require_enc_hex(), 1);
|
|
2215
|
+
var import_enc_utf8 = /* @__PURE__ */ __toESM(require_enc_utf8(), 1);
|
|
2216
|
+
var import_md5 = /* @__PURE__ */ __toESM(require_md5(), 1);
|
|
2217
|
+
var import_mode_ecb = /* @__PURE__ */ __toESM(require_mode_ecb(), 1);
|
|
2218
|
+
require_pad_ansix923();
|
|
2219
|
+
var import_pad_iso10126 = /* @__PURE__ */ __toESM(require_pad_iso10126(), 1);
|
|
2220
|
+
var import_pad_nopadding = /* @__PURE__ */ __toESM(require_pad_nopadding(), 1);
|
|
2221
|
+
var import_pad_pkcs7 = /* @__PURE__ */ __toESM(require_pad_pkcs7(), 1);
|
|
2222
|
+
var import_pad_zeropadding = /* @__PURE__ */ __toESM(require_pad_zeropadding(), 1);
|
|
2223
|
+
var import_sha1 = /* @__PURE__ */ __toESM(require_sha1(), 1);
|
|
17
2224
|
/** PBKDF2 默认迭代次数。 */
|
|
18
2225
|
const defaultPbkdf2Iterations = 6e5;
|
|
19
2226
|
/** PBKDF2 允许的最小迭代次数。 */
|
|
@@ -206,7 +2413,7 @@ function FixedTimeEquals(left, right) {
|
|
|
206
2413
|
* @returns 32 字符小写十六进制摘要。
|
|
207
2414
|
*/
|
|
208
2415
|
function MD5Encrypt(value) {
|
|
209
|
-
return
|
|
2416
|
+
return (0, import_md5.default)(value).toString(import_enc_hex.default);
|
|
210
2417
|
}
|
|
211
2418
|
/**
|
|
212
2419
|
* 计算 SHA-1 摘要并返回大写十六进制文本。
|
|
@@ -216,7 +2423,7 @@ function MD5Encrypt(value) {
|
|
|
216
2423
|
* @returns 40 字符大写十六进制摘要。
|
|
217
2424
|
*/
|
|
218
2425
|
function SHA1Encrypt(value) {
|
|
219
|
-
return
|
|
2426
|
+
return (0, import_sha1.default)(value).toString(import_enc_hex.default).toUpperCase();
|
|
220
2427
|
}
|
|
221
2428
|
/**
|
|
222
2429
|
* 计算 SHA-256 摘要。
|
|
@@ -406,32 +2613,32 @@ async function HKDFSHA256(inputKeyMaterial, salt = /* @__PURE__ */ new Uint8Arra
|
|
|
406
2613
|
function AESEncrypt(dataStr, key, vector, cipherMode = "CBC", paddingMode = "PKCS7") {
|
|
407
2614
|
if (dataStr.trim().length === 0 || key.trim().length === 0 || vector.trim().length === 0) return null;
|
|
408
2615
|
assertAesCipherMode(cipherMode);
|
|
409
|
-
let padding =
|
|
2616
|
+
let padding = import_pad_pkcs7.default;
|
|
410
2617
|
switch (paddingMode) {
|
|
411
2618
|
case "None":
|
|
412
|
-
padding =
|
|
2619
|
+
padding = import_pad_nopadding.default;
|
|
413
2620
|
break;
|
|
414
2621
|
case "PKCS7": break;
|
|
415
2622
|
case "Zeros":
|
|
416
|
-
padding =
|
|
2623
|
+
padding = import_pad_zeropadding.default;
|
|
417
2624
|
break;
|
|
418
2625
|
case "ANSIX923":
|
|
419
|
-
padding =
|
|
2626
|
+
padding = import_core.default.pad.AnsiX923;
|
|
420
2627
|
break;
|
|
421
2628
|
case "ISO10126":
|
|
422
|
-
padding =
|
|
2629
|
+
padding = import_pad_iso10126.default;
|
|
423
2630
|
break;
|
|
424
2631
|
default: throw new RangeError("不支持当前 `paddingMode`。");
|
|
425
2632
|
}
|
|
426
2633
|
if (paddingMode === "None" && encodeUtf8(dataStr).length % 16 !== 0) throw new RangeError("当 `paddingMode` 为 `None` 时,AES 明文长度必须是 16 字节的整数倍。");
|
|
427
|
-
const keyBytes =
|
|
428
|
-
const vectorBytes =
|
|
429
|
-
return
|
|
2634
|
+
const keyBytes = import_enc_utf8.default.parse(key.padEnd(32, "f").slice(0, 32));
|
|
2635
|
+
const vectorBytes = import_enc_utf8.default.parse(vector.padEnd(16, "f").slice(0, 16));
|
|
2636
|
+
return import_aes.default.encrypt(dataStr, keyBytes, cipherMode === "CBC" ? {
|
|
430
2637
|
iv: vectorBytes,
|
|
431
2638
|
padding
|
|
432
2639
|
} : {
|
|
433
2640
|
iv: vectorBytes,
|
|
434
|
-
mode:
|
|
2641
|
+
mode: import_mode_ecb.default,
|
|
435
2642
|
padding
|
|
436
2643
|
}).toString();
|
|
437
2644
|
}
|
|
@@ -450,35 +2657,35 @@ function AESEncrypt(dataStr, key, vector, cipherMode = "CBC", paddingMode = "PKC
|
|
|
450
2657
|
function AESDecrypt(dataStr, key, vector, cipherMode = "CBC", paddingMode = "PKCS7") {
|
|
451
2658
|
if (dataStr.trim().length === 0 || key.trim().length === 0 || vector.trim().length === 0) return null;
|
|
452
2659
|
assertAesCipherMode(cipherMode);
|
|
453
|
-
let padding =
|
|
2660
|
+
let padding = import_pad_pkcs7.default;
|
|
454
2661
|
switch (paddingMode) {
|
|
455
2662
|
case "None":
|
|
456
|
-
padding =
|
|
2663
|
+
padding = import_pad_nopadding.default;
|
|
457
2664
|
break;
|
|
458
2665
|
case "PKCS7": break;
|
|
459
2666
|
case "Zeros":
|
|
460
|
-
padding =
|
|
2667
|
+
padding = import_pad_nopadding.default;
|
|
461
2668
|
break;
|
|
462
2669
|
case "ANSIX923":
|
|
463
|
-
padding =
|
|
2670
|
+
padding = import_core.default.pad.AnsiX923;
|
|
464
2671
|
break;
|
|
465
2672
|
case "ISO10126":
|
|
466
|
-
padding =
|
|
2673
|
+
padding = import_pad_iso10126.default;
|
|
467
2674
|
break;
|
|
468
2675
|
default: throw new RangeError("不支持当前 `paddingMode`。");
|
|
469
2676
|
}
|
|
470
2677
|
const ciphertextBytes = decodeBase64Bytes(dataStr);
|
|
471
2678
|
if (ciphertextBytes.length === 0 || ciphertextBytes.length % 16 !== 0) throw new RangeError("AES 密文必须至少包含一个完整的 16 字节块。");
|
|
472
|
-
const keyBytes =
|
|
473
|
-
const vectorBytes =
|
|
474
|
-
return createDecodedText(
|
|
2679
|
+
const keyBytes = import_enc_utf8.default.parse(key.padEnd(32, "f").slice(0, 32));
|
|
2680
|
+
const vectorBytes = import_enc_utf8.default.parse(vector.padEnd(16, "f").slice(0, 16));
|
|
2681
|
+
return createDecodedText(import_aes.default.decrypt(dataStr, keyBytes, cipherMode === "CBC" ? {
|
|
475
2682
|
iv: vectorBytes,
|
|
476
2683
|
padding
|
|
477
2684
|
} : {
|
|
478
2685
|
iv: vectorBytes,
|
|
479
|
-
mode:
|
|
2686
|
+
mode: import_mode_ecb.default,
|
|
480
2687
|
padding
|
|
481
|
-
}).toString(
|
|
2688
|
+
}).toString(import_enc_utf8.default));
|
|
482
2689
|
}
|
|
483
2690
|
/**
|
|
484
2691
|
* 使用 SHA-256 归一化文本密钥,再以 AES-256-GCM 认证加密 UTF-8 文本。
|