secure-ls2 2.1.6 → 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/coverage/clover.xml +2 -2
- package/coverage/coverage-final.json +1 -1
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov.info +2 -2
- package/dist/secure-ls2.js +1523 -1523
- package/dist/secure-ls2.js.map +1 -1
- package/dist/secure-ls2.min.js +2 -2
- package/dist/secure-ls2.min.js.map +1 -1
- package/package.json +9 -9
package/dist/secure-ls2.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* secure-ls2 - v2.1.
|
|
2
|
+
* secure-ls2 - v2.1.7
|
|
3
3
|
* URL - https://github.com/softvar/secure-ls
|
|
4
4
|
*
|
|
5
5
|
* The MIT License (MIT)
|
|
@@ -46,273 +46,857 @@
|
|
|
46
46
|
return /******/ (() => { // webpackBootstrap
|
|
47
47
|
/******/ var __webpack_modules__ = ({
|
|
48
48
|
|
|
49
|
-
/***/ "./
|
|
50
|
-
|
|
51
|
-
!*** ./
|
|
52
|
-
|
|
53
|
-
(
|
|
54
|
-
|
|
55
|
-
;(function (root, factory, undef) {
|
|
56
|
-
if (true) {
|
|
57
|
-
// CommonJS
|
|
58
|
-
module.exports = exports = factory(__webpack_require__(/*! ./core */ "./node_modules/crypto-js/core.js"), __webpack_require__(/*! ./enc-base64 */ "./node_modules/crypto-js/enc-base64.js"), __webpack_require__(/*! ./md5 */ "./node_modules/crypto-js/md5.js"), __webpack_require__(/*! ./evpkdf */ "./node_modules/crypto-js/evpkdf.js"), __webpack_require__(/*! ./cipher-core */ "./node_modules/crypto-js/cipher-core.js"));
|
|
59
|
-
}
|
|
60
|
-
else // removed by dead control flow
|
|
61
|
-
{}
|
|
62
|
-
}(this, function (CryptoJS) {
|
|
63
|
-
|
|
64
|
-
(function () {
|
|
65
|
-
// Shortcuts
|
|
66
|
-
var C = CryptoJS;
|
|
67
|
-
var C_lib = C.lib;
|
|
68
|
-
var BlockCipher = C_lib.BlockCipher;
|
|
69
|
-
var C_algo = C.algo;
|
|
49
|
+
/***/ "./src/Base64.js"
|
|
50
|
+
/*!***********************!*\
|
|
51
|
+
!*** ./src/Base64.js ***!
|
|
52
|
+
\***********************/
|
|
53
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
70
54
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
55
|
+
"use strict";
|
|
56
|
+
__webpack_require__.r(__webpack_exports__);
|
|
57
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
58
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
59
|
+
/* harmony export */ });
|
|
60
|
+
const Base64 = {
|
|
61
|
+
_keyStr: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
|
|
62
|
+
encode: function (e) {
|
|
63
|
+
let t = '';
|
|
64
|
+
let n, r, i, s, o, u, a;
|
|
65
|
+
let f = 0;
|
|
66
|
+
e = Base64._utf8Encode(e);
|
|
67
|
+
while (f < e.length) {
|
|
68
|
+
n = e.charCodeAt(f++);
|
|
69
|
+
r = e.charCodeAt(f++);
|
|
70
|
+
i = e.charCodeAt(f++);
|
|
71
|
+
s = n >> 2;
|
|
72
|
+
o = (n & 3) << 4 | r >> 4;
|
|
73
|
+
u = (r & 15) << 2 | i >> 6;
|
|
74
|
+
a = i & 63;
|
|
75
|
+
if (isNaN(r)) {
|
|
76
|
+
u = a = 64;
|
|
77
|
+
} else if (isNaN(i)) {
|
|
78
|
+
a = 64;
|
|
79
|
+
}
|
|
80
|
+
t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) + this._keyStr.charAt(u) + this._keyStr.charAt(a);
|
|
81
|
+
}
|
|
82
|
+
return t;
|
|
83
|
+
},
|
|
84
|
+
decode: function (e) {
|
|
85
|
+
let t = '';
|
|
86
|
+
let n, r, i;
|
|
87
|
+
let s, o, u, a;
|
|
88
|
+
let f = 0;
|
|
89
|
+
e = e.replace(/[^A-Za-z0-9+/=]/g, '');
|
|
90
|
+
while (f < e.length) {
|
|
91
|
+
s = this._keyStr.indexOf(e.charAt(f++));
|
|
92
|
+
o = this._keyStr.indexOf(e.charAt(f++));
|
|
93
|
+
u = this._keyStr.indexOf(e.charAt(f++));
|
|
94
|
+
a = this._keyStr.indexOf(e.charAt(f++));
|
|
95
|
+
n = s << 2 | o >> 4;
|
|
96
|
+
r = (o & 15) << 4 | u >> 2;
|
|
97
|
+
i = (u & 3) << 6 | a;
|
|
98
|
+
t = t + String.fromCharCode(n);
|
|
99
|
+
if (u !== 64) {
|
|
100
|
+
t = t + String.fromCharCode(r);
|
|
101
|
+
}
|
|
102
|
+
if (a !== 64) {
|
|
103
|
+
t = t + String.fromCharCode(i);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
t = Base64._utf8Decode(t);
|
|
107
|
+
return t;
|
|
108
|
+
},
|
|
109
|
+
_utf8Encode: function (e) {
|
|
110
|
+
e = e.replace(/\r\n/g, '\n');
|
|
111
|
+
let t = '';
|
|
112
|
+
for (let n = 0; n < e.length; n++) {
|
|
113
|
+
let r = e.charCodeAt(n);
|
|
114
|
+
if (r < 128) {
|
|
115
|
+
t += String.fromCharCode(r);
|
|
116
|
+
} else if (r > 127 && r < 2048) {
|
|
117
|
+
t += String.fromCharCode(r >> 6 | 192);
|
|
118
|
+
t += String.fromCharCode(r & 63 | 128);
|
|
119
|
+
} else {
|
|
120
|
+
t += String.fromCharCode(r >> 12 | 224);
|
|
121
|
+
t += String.fromCharCode(r >> 6 & 63 | 128);
|
|
122
|
+
t += String.fromCharCode(r & 63 | 128);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return t;
|
|
126
|
+
},
|
|
127
|
+
_utf8Decode: function (e) {
|
|
128
|
+
let t = '';
|
|
129
|
+
let n = 0;
|
|
130
|
+
let r, c2, c3;
|
|
131
|
+
r = c2 = 0;
|
|
132
|
+
while (n < e.length) {
|
|
133
|
+
r = e.charCodeAt(n);
|
|
134
|
+
if (r < 128) {
|
|
135
|
+
t += String.fromCharCode(r);
|
|
136
|
+
n++;
|
|
137
|
+
} else if (r > 191 && r < 224) {
|
|
138
|
+
c2 = e.charCodeAt(n + 1);
|
|
139
|
+
t += String.fromCharCode((r & 31) << 6 | c2 & 63);
|
|
140
|
+
n += 2;
|
|
141
|
+
} else {
|
|
142
|
+
c2 = e.charCodeAt(n + 1);
|
|
143
|
+
c3 = e.charCodeAt(n + 2);
|
|
144
|
+
t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63);
|
|
145
|
+
n += 3;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return t;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Base64);
|
|
82
152
|
|
|
83
|
-
|
|
84
|
-
(function () {
|
|
85
|
-
// Compute double table
|
|
86
|
-
var d = [];
|
|
87
|
-
for (var i = 0; i < 256; i++) {
|
|
88
|
-
if (i < 128) {
|
|
89
|
-
d[i] = i << 1;
|
|
90
|
-
} else {
|
|
91
|
-
d[i] = (i << 1) ^ 0x11b;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
153
|
+
/***/ },
|
|
94
154
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
|
|
101
|
-
sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
|
|
102
|
-
SBOX[x] = sx;
|
|
103
|
-
INV_SBOX[sx] = x;
|
|
155
|
+
/***/ "./src/SecureLS.js"
|
|
156
|
+
/*!*************************!*\
|
|
157
|
+
!*** ./src/SecureLS.js ***!
|
|
158
|
+
\*************************/
|
|
159
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
104
160
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
161
|
+
"use strict";
|
|
162
|
+
__webpack_require__.r(__webpack_exports__);
|
|
163
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
164
|
+
/* harmony export */ SecureLS: () => (/* binding */ SecureLS)
|
|
165
|
+
/* harmony export */ });
|
|
166
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./src/constants.js");
|
|
167
|
+
/* harmony import */ var _enc_utf8__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./enc-utf8 */ "./src/enc-utf8.js");
|
|
168
|
+
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils */ "./src/utils.js");
|
|
169
|
+
/* harmony import */ var crypto_js_aes__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! crypto-js/aes */ "./node_modules/crypto-js/aes.js");
|
|
170
|
+
/* harmony import */ var crypto_js_aes__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(crypto_js_aes__WEBPACK_IMPORTED_MODULE_3__);
|
|
171
|
+
/* harmony import */ var crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! crypto-js/rabbit */ "./node_modules/crypto-js/rabbit.js");
|
|
172
|
+
/* harmony import */ var crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4__);
|
|
173
|
+
/* harmony import */ var crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! crypto-js/rc4 */ "./node_modules/crypto-js/rc4.js");
|
|
174
|
+
/* harmony import */ var crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5__);
|
|
175
|
+
/* harmony import */ var crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! crypto-js/tripledes */ "./node_modules/crypto-js/tripledes.js");
|
|
176
|
+
/* harmony import */ var crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6__);
|
|
177
|
+
/* harmony import */ var lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! lz-string/libs/lz-string */ "./node_modules/lz-string/libs/lz-string.js");
|
|
178
|
+
/* harmony import */ var lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7__);
|
|
179
|
+
/* harmony import */ var _Base64__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Base64 */ "./src/Base64.js");
|
|
109
180
|
|
|
110
|
-
// Compute sub bytes, mix columns tables
|
|
111
|
-
var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
|
|
112
|
-
SUB_MIX_0[x] = (t << 24) | (t >>> 8);
|
|
113
|
-
SUB_MIX_1[x] = (t << 16) | (t >>> 16);
|
|
114
|
-
SUB_MIX_2[x] = (t << 8) | (t >>> 24);
|
|
115
|
-
SUB_MIX_3[x] = t;
|
|
116
181
|
|
|
117
|
-
// Compute inv sub bytes, inv mix columns tables
|
|
118
|
-
var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
|
|
119
|
-
INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
|
|
120
|
-
INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
|
|
121
|
-
INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
|
|
122
|
-
INV_SUB_MIX_3[sx] = t;
|
|
123
182
|
|
|
124
|
-
// Compute next counter
|
|
125
|
-
if (!x) {
|
|
126
|
-
x = xi = 1;
|
|
127
|
-
} else {
|
|
128
|
-
x = x2 ^ d[d[d[x8 ^ x2]]];
|
|
129
|
-
xi ^= d[d[xi]];
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}());
|
|
133
183
|
|
|
134
|
-
// Precomputed Rcon lookup
|
|
135
|
-
var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
|
|
136
184
|
|
|
137
|
-
/**
|
|
138
|
-
* AES block cipher algorithm.
|
|
139
|
-
*/
|
|
140
|
-
var AES = C_algo.AES = BlockCipher.extend({
|
|
141
|
-
_doReset: function () {
|
|
142
|
-
var t;
|
|
143
185
|
|
|
144
|
-
// Skip reset of nRounds has been set before and key did not change
|
|
145
|
-
if (this._nRounds && this._keyPriorReset === this._key) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
186
|
|
|
149
|
-
// Shortcuts
|
|
150
|
-
var key = this._keyPriorReset = this._key;
|
|
151
|
-
var keyWords = key.words;
|
|
152
|
-
var keySize = key.sigBytes / 4;
|
|
153
187
|
|
|
154
|
-
// Compute number of rounds
|
|
155
|
-
var nRounds = this._nRounds = keySize + 6;
|
|
156
188
|
|
|
157
|
-
|
|
158
|
-
|
|
189
|
+
const encryptors = {
|
|
190
|
+
[_constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.AES]: (crypto_js_aes__WEBPACK_IMPORTED_MODULE_3___default()),
|
|
191
|
+
[_constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.DES]: (crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6___default()),
|
|
192
|
+
[_constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.RABBIT]: (crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4___default()),
|
|
193
|
+
[_constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.RC4]: (crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5___default())
|
|
194
|
+
};
|
|
195
|
+
class SecureLS {
|
|
196
|
+
constructor({
|
|
197
|
+
encryptionSecret = '',
|
|
198
|
+
encryptionNamespace = '',
|
|
199
|
+
isCompression = true,
|
|
200
|
+
encodingType = _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.BASE64,
|
|
201
|
+
storage = localStorage,
|
|
202
|
+
metaKey = _constants__WEBPACK_IMPORTED_MODULE_0__["default"].metaKey
|
|
203
|
+
} = {}) {
|
|
204
|
+
// Assign libraries and utilities
|
|
205
|
+
Object.assign(this, {
|
|
206
|
+
_name: 'secure-ls',
|
|
207
|
+
Base64: _Base64__WEBPACK_IMPORTED_MODULE_8__["default"],
|
|
208
|
+
LZString: {
|
|
209
|
+
compressToUTF16: lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7__.compressToUTF16,
|
|
210
|
+
decompressFromUTF16: lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7__.decompressFromUTF16
|
|
211
|
+
},
|
|
212
|
+
AES: (crypto_js_aes__WEBPACK_IMPORTED_MODULE_3___default()),
|
|
213
|
+
DES: (crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6___default()),
|
|
214
|
+
RABBIT: (crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4___default()),
|
|
215
|
+
RC4: (crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5___default()),
|
|
216
|
+
enc: _enc_utf8__WEBPACK_IMPORTED_MODULE_1__["default"]
|
|
217
|
+
});
|
|
159
218
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
// Sub word
|
|
173
|
-
t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
|
|
219
|
+
// Configuration and property assignment
|
|
220
|
+
this.config = {
|
|
221
|
+
encryptionSecret,
|
|
222
|
+
encryptionNamespace,
|
|
223
|
+
isCompression,
|
|
224
|
+
encodingType: encodingType.toLowerCase(),
|
|
225
|
+
storage,
|
|
226
|
+
metaKey
|
|
227
|
+
};
|
|
228
|
+
this.encryptionSecret = encryptionSecret;
|
|
229
|
+
this.storage = storage;
|
|
230
|
+
this.metaKey = metaKey;
|
|
174
231
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
232
|
+
// Initialize the class
|
|
233
|
+
this.init();
|
|
234
|
+
}
|
|
235
|
+
init() {
|
|
236
|
+
let metaData = this.getMetaData();
|
|
237
|
+
this._isBase64 = this._isBase64EncryptionType();
|
|
238
|
+
this._isAES = this._isAESEncryptionType();
|
|
239
|
+
this._isDES = this._isDESEncryptionType();
|
|
240
|
+
this._isRabbit = this._isRabbitEncryptionType();
|
|
241
|
+
this._isRC4 = this._isRC4EncryptionType();
|
|
242
|
+
this._isCompression = this._isDataCompressionEnabled();
|
|
181
243
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
244
|
+
// fill the already present keys to the list of keys being used by secure-ls
|
|
245
|
+
this.allKeys = metaData.keys || this.resetAllKeys();
|
|
246
|
+
}
|
|
247
|
+
_isBase64EncryptionType() {
|
|
248
|
+
return _Base64__WEBPACK_IMPORTED_MODULE_8__["default"] && (typeof this.config.encodingType === 'undefined' || this.config.encodingType === _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.BASE64);
|
|
249
|
+
}
|
|
250
|
+
_isAESEncryptionType() {
|
|
251
|
+
return (crypto_js_aes__WEBPACK_IMPORTED_MODULE_3___default()) && this.config.encodingType === _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.AES;
|
|
252
|
+
}
|
|
253
|
+
_isDESEncryptionType() {
|
|
254
|
+
return (crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6___default()) && this.config.encodingType === _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.DES;
|
|
255
|
+
}
|
|
256
|
+
_isRabbitEncryptionType() {
|
|
257
|
+
return (crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4___default()) && this.config.encodingType === _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.RABBIT;
|
|
258
|
+
}
|
|
259
|
+
_isRC4EncryptionType() {
|
|
260
|
+
return (crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5___default()) && this.config.encodingType === _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.RC4;
|
|
261
|
+
}
|
|
262
|
+
_isDataCompressionEnabled() {
|
|
263
|
+
return this.config.isCompression;
|
|
264
|
+
}
|
|
265
|
+
getEncryptionSecret(key) {
|
|
266
|
+
let metaData = this.getMetaData();
|
|
267
|
+
let obj = _utils__WEBPACK_IMPORTED_MODULE_2__["default"].getObjectFromKey(metaData.keys, key);
|
|
268
|
+
if (!obj) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (this._isAES || this._isDES || this._isRabbit || this._isRC4) {
|
|
272
|
+
if (typeof this.config.encryptionSecret === 'undefined') {
|
|
273
|
+
this.encryptionSecret = obj.s;
|
|
274
|
+
if (!this.encryptionSecret) {
|
|
275
|
+
this.encryptionSecret = _utils__WEBPACK_IMPORTED_MODULE_2__["default"].generateSecretKey();
|
|
276
|
+
this.setMetaData();
|
|
277
|
+
}
|
|
278
|
+
} else {
|
|
279
|
+
this.encryptionSecret = this.config.encryptionSecret || obj.s || '';
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
getEncryptionType() {
|
|
284
|
+
const encodingType = this.config.encodingType;
|
|
285
|
+
return encodingType ? encodingType.toLowerCase() : _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.BASE64;
|
|
286
|
+
}
|
|
287
|
+
getDataFromLocalStorage(key) {
|
|
288
|
+
return this.storage.getItem(key, true);
|
|
289
|
+
}
|
|
290
|
+
setDataToLocalStorage(key, data) {
|
|
291
|
+
this.storage.setItem(key, data);
|
|
292
|
+
}
|
|
293
|
+
setMetaData() {
|
|
294
|
+
let dataToStore = this.processData({
|
|
295
|
+
keys: this.allKeys
|
|
296
|
+
}, true);
|
|
185
297
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
298
|
+
// Store the data to localStorage
|
|
299
|
+
this.setDataToLocalStorage(this.getMetaKey(), dataToStore);
|
|
300
|
+
}
|
|
301
|
+
getMetaData() {
|
|
302
|
+
return this.get(this.getMetaKey(), true) || {};
|
|
303
|
+
}
|
|
304
|
+
getMetaKey() {
|
|
305
|
+
return this.metaKey + (this.config.encryptionNamespace ? '__' + this.config.encryptionNamespace : '');
|
|
306
|
+
}
|
|
307
|
+
resetAllKeys() {
|
|
308
|
+
this.allKeys = [];
|
|
309
|
+
return [];
|
|
310
|
+
}
|
|
311
|
+
processData(data, isAllKeysData) {
|
|
312
|
+
if (data === null || data === undefined || data === '') {
|
|
313
|
+
return '';
|
|
314
|
+
}
|
|
315
|
+
let jsonData;
|
|
316
|
+
try {
|
|
317
|
+
jsonData = JSON.stringify(data);
|
|
318
|
+
} catch (err) {
|
|
319
|
+
throw new Error('Could not stringify data', err);
|
|
320
|
+
}
|
|
190
321
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
322
|
+
// Encode Based on encoding type
|
|
323
|
+
// If not set, default to Base64 for securing data
|
|
324
|
+
let encodedData = jsonData;
|
|
325
|
+
if (this._isBase64 || isAllKeysData) {
|
|
326
|
+
encodedData = _Base64__WEBPACK_IMPORTED_MODULE_8__["default"].encode(jsonData);
|
|
327
|
+
} else {
|
|
328
|
+
const encryptor = encryptors[this.getEncryptionType()];
|
|
329
|
+
if (encryptor) {
|
|
330
|
+
encodedData = encryptor.encrypt(jsonData, this.encryptionSecret);
|
|
331
|
+
}
|
|
332
|
+
encodedData = encodedData && encodedData.toString();
|
|
333
|
+
}
|
|
196
334
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
},
|
|
335
|
+
// Compress data if set to true
|
|
336
|
+
let compressedData = encodedData;
|
|
337
|
+
if (this._isCompression || isAllKeysData) {
|
|
338
|
+
compressedData = this.LZString.compressToUTF16(encodedData);
|
|
339
|
+
}
|
|
340
|
+
return compressedData;
|
|
341
|
+
}
|
|
205
342
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
343
|
+
// PUBLIC APIs
|
|
344
|
+
getAllKeys() {
|
|
345
|
+
let data = this.getMetaData();
|
|
346
|
+
return _utils__WEBPACK_IMPORTED_MODULE_2__["default"].extractKeyNames(data) || [];
|
|
347
|
+
}
|
|
348
|
+
get(key, isAllKeysData) {
|
|
349
|
+
let decodedData = '';
|
|
350
|
+
let jsonData = '';
|
|
351
|
+
if (!_utils__WEBPACK_IMPORTED_MODULE_2__["default"].is(key)) {
|
|
352
|
+
_utils__WEBPACK_IMPORTED_MODULE_2__["default"].warn(_constants__WEBPACK_IMPORTED_MODULE_0__["default"].WarningEnum.KEY_NOT_PROVIDED);
|
|
353
|
+
return jsonData;
|
|
354
|
+
}
|
|
355
|
+
let data = this.getDataFromLocalStorage(key);
|
|
356
|
+
if (!data) {
|
|
357
|
+
return jsonData;
|
|
358
|
+
}
|
|
359
|
+
let deCompressedData = data; // saves else
|
|
360
|
+
if (this._isCompression || isAllKeysData) {
|
|
361
|
+
// meta data always compressed
|
|
362
|
+
deCompressedData = this.LZString.decompressFromUTF16(data);
|
|
363
|
+
}
|
|
364
|
+
decodedData = deCompressedData; // saves else
|
|
365
|
+
if (this._isBase64 || isAllKeysData) {
|
|
366
|
+
// meta data always Base64
|
|
367
|
+
decodedData = _Base64__WEBPACK_IMPORTED_MODULE_8__["default"].decode(deCompressedData);
|
|
368
|
+
} else {
|
|
369
|
+
this.getEncryptionSecret(key);
|
|
370
|
+
const encryptor = encryptors[this.getEncryptionType()];
|
|
371
|
+
if (encryptor) {
|
|
372
|
+
const bytes = encryptor.decrypt(deCompressedData.toString(), this.encryptionSecret);
|
|
373
|
+
if (bytes) {
|
|
374
|
+
decodedData = bytes.toString(_enc_utf8__WEBPACK_IMPORTED_MODULE_1__["default"]._Utf8);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
try {
|
|
379
|
+
jsonData = JSON.parse(decodedData);
|
|
380
|
+
} catch (err) {
|
|
381
|
+
throw new Error('Could not parse JSON', err);
|
|
382
|
+
}
|
|
383
|
+
return jsonData;
|
|
384
|
+
}
|
|
385
|
+
set(key, data) {
|
|
386
|
+
let dataToStore = '';
|
|
387
|
+
if (!_utils__WEBPACK_IMPORTED_MODULE_2__["default"].is(key)) {
|
|
388
|
+
_utils__WEBPACK_IMPORTED_MODULE_2__["default"].warn(_constants__WEBPACK_IMPORTED_MODULE_0__["default"].WarningEnum.KEY_NOT_PROVIDED);
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
this.getEncryptionSecret(key);
|
|
209
392
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
393
|
+
// add key(s) to Array if not already added, only for keys other than meta key
|
|
394
|
+
if (!(String(key) === String(this.metaKey))) {
|
|
395
|
+
if (!_utils__WEBPACK_IMPORTED_MODULE_2__["default"].isKeyPresent(this.allKeys, key)) {
|
|
396
|
+
this.allKeys.push({
|
|
397
|
+
k: key,
|
|
398
|
+
s: this.encryptionSecret
|
|
399
|
+
});
|
|
400
|
+
this.setMetaData();
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
dataToStore = this.processData(data);
|
|
404
|
+
// Store the data to localStorage
|
|
405
|
+
this.setDataToLocalStorage(key, dataToStore);
|
|
406
|
+
}
|
|
407
|
+
remove(key) {
|
|
408
|
+
if (!_utils__WEBPACK_IMPORTED_MODULE_2__["default"].is(key)) {
|
|
409
|
+
_utils__WEBPACK_IMPORTED_MODULE_2__["default"].warn(_constants__WEBPACK_IMPORTED_MODULE_0__["default"].WarningEnum.KEY_NOT_PROVIDED);
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
if (key === this.metaKey && this.getAllKeys().length) {
|
|
413
|
+
_utils__WEBPACK_IMPORTED_MODULE_2__["default"].warn(_constants__WEBPACK_IMPORTED_MODULE_0__["default"].WarningEnum.META_KEY_REMOVE);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
if (_utils__WEBPACK_IMPORTED_MODULE_2__["default"].isKeyPresent(this.allKeys, key)) {
|
|
417
|
+
_utils__WEBPACK_IMPORTED_MODULE_2__["default"].removeFromKeysList(this.allKeys, key);
|
|
418
|
+
this.setMetaData();
|
|
419
|
+
}
|
|
420
|
+
this.storage.removeItem(key);
|
|
421
|
+
}
|
|
422
|
+
removeAll() {
|
|
423
|
+
let keys = this.getAllKeys();
|
|
424
|
+
for (let i = 0; i < keys.length; i++) {
|
|
425
|
+
this.storage.removeItem(keys[i]);
|
|
426
|
+
}
|
|
427
|
+
this.storage.removeItem(this.metaKey);
|
|
428
|
+
this.resetAllKeys();
|
|
429
|
+
}
|
|
430
|
+
clear() {
|
|
431
|
+
this.storage.clear();
|
|
432
|
+
this.resetAllKeys();
|
|
433
|
+
}
|
|
434
|
+
}
|
|
215
435
|
|
|
216
|
-
|
|
436
|
+
/***/ },
|
|
217
437
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
438
|
+
/***/ "./src/WordArray.js"
|
|
439
|
+
/*!**************************!*\
|
|
440
|
+
!*** ./src/WordArray.js ***!
|
|
441
|
+
\**************************/
|
|
442
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
223
443
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
444
|
+
"use strict";
|
|
445
|
+
__webpack_require__.r(__webpack_exports__);
|
|
446
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
447
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
448
|
+
/* harmony export */ });
|
|
449
|
+
/*
|
|
450
|
+
ES6 compatible port of CryptoJS - WordArray for PBKDF2 password key generation
|
|
227
451
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
var s2 = M[offset + 2] ^ keySchedule[2];
|
|
232
|
-
var s3 = M[offset + 3] ^ keySchedule[3];
|
|
452
|
+
Source: https://github.com/brix/crypto-js
|
|
453
|
+
LICENSE: MIT
|
|
454
|
+
*/
|
|
233
455
|
|
|
234
|
-
|
|
235
|
-
|
|
456
|
+
let CryptoJSWordArray = {
|
|
457
|
+
random: function (nBytes) {
|
|
458
|
+
let words = [];
|
|
459
|
+
let r = function (mw) {
|
|
460
|
+
let mz = 0x3ade68b1;
|
|
461
|
+
let mask = 0xffffffff;
|
|
462
|
+
return function () {
|
|
463
|
+
mz = 0x9069 * (mz & 0xffff) + (mz >> 0x10) & mask;
|
|
464
|
+
mw = 0x4650 * (mw & 0xffff) + (mw >> 0x10) & mask;
|
|
465
|
+
let result = (mz << 0x10) + mw & mask;
|
|
466
|
+
result /= 0x100000000;
|
|
467
|
+
result += 0.5;
|
|
468
|
+
return result * (Math.random() > 0.5 ? 1 : -1);
|
|
469
|
+
};
|
|
470
|
+
};
|
|
471
|
+
for (let i = 0, rcache; i < nBytes; i += 4) {
|
|
472
|
+
let _r = r((rcache || Math.random()) * 0x100000000);
|
|
473
|
+
rcache = _r() * 0x3ade67b7;
|
|
474
|
+
words.push(_r() * 0x100000000 | 0);
|
|
475
|
+
}
|
|
476
|
+
return new CryptoJSWordArray.Set(words, nBytes);
|
|
477
|
+
},
|
|
478
|
+
Set: function (words, sigBytes) {
|
|
479
|
+
words = this.words = words || [];
|
|
480
|
+
if (sigBytes !== undefined) {
|
|
481
|
+
this.sigBytes = sigBytes;
|
|
482
|
+
} else {
|
|
483
|
+
this.sigBytes = words.length * 8;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (CryptoJSWordArray);
|
|
236
488
|
|
|
237
|
-
|
|
238
|
-
for (var round = 1; round < nRounds; round++) {
|
|
239
|
-
// Shift rows, sub bytes, mix columns, add round key
|
|
240
|
-
var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
|
|
241
|
-
var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
|
|
242
|
-
var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
|
|
243
|
-
var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
|
|
489
|
+
/***/ },
|
|
244
490
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
491
|
+
/***/ "./src/constants.js"
|
|
492
|
+
/*!**************************!*\
|
|
493
|
+
!*** ./src/constants.js ***!
|
|
494
|
+
\**************************/
|
|
495
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
251
496
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
497
|
+
"use strict";
|
|
498
|
+
__webpack_require__.r(__webpack_exports__);
|
|
499
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
500
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
501
|
+
/* harmony export */ });
|
|
502
|
+
const WarningEnum = {
|
|
503
|
+
KEY_NOT_PROVIDED: 'keyNotProvided',
|
|
504
|
+
META_KEY_REMOVE: 'metaKeyRemove',
|
|
505
|
+
DEFAULT_TEXT: 'defaultText'
|
|
506
|
+
};
|
|
507
|
+
const WarningTypes = {};
|
|
508
|
+
WarningTypes[WarningEnum.KEY_NOT_PROVIDED] = 'Secure LS: Key not provided. Aborting operation!';
|
|
509
|
+
WarningTypes[WarningEnum.META_KEY_REMOVE] = `Secure LS: Meta key can not be removed
|
|
510
|
+
unless all keys created by Secure LS are removed!`;
|
|
511
|
+
WarningTypes[WarningEnum.DEFAULT_TEXT] = `Unexpected output`;
|
|
512
|
+
const constants = {
|
|
513
|
+
WarningEnum: WarningEnum,
|
|
514
|
+
WarningTypes: WarningTypes,
|
|
515
|
+
EncrytionTypes: {
|
|
516
|
+
BASE64: 'base64',
|
|
517
|
+
AES: 'aes',
|
|
518
|
+
DES: 'des',
|
|
519
|
+
RABBIT: 'rabbit',
|
|
520
|
+
RC4: 'rc4'
|
|
521
|
+
},
|
|
522
|
+
metaKey: '_secure__ls__metadata',
|
|
523
|
+
secretPhrase: 's3cr3t$#@135^&*246'
|
|
524
|
+
};
|
|
525
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (constants);
|
|
257
526
|
|
|
258
|
-
|
|
259
|
-
M[offset] = t0;
|
|
260
|
-
M[offset + 1] = t1;
|
|
261
|
-
M[offset + 2] = t2;
|
|
262
|
-
M[offset + 3] = t3;
|
|
263
|
-
},
|
|
527
|
+
/***/ },
|
|
264
528
|
|
|
265
|
-
|
|
266
|
-
|
|
529
|
+
/***/ "./src/enc-utf8.js"
|
|
530
|
+
/*!*************************!*\
|
|
531
|
+
!*** ./src/enc-utf8.js ***!
|
|
532
|
+
\*************************/
|
|
533
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
267
534
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
*/
|
|
276
|
-
C.AES = BlockCipher._createHelper(AES);
|
|
277
|
-
}());
|
|
535
|
+
"use strict";
|
|
536
|
+
__webpack_require__.r(__webpack_exports__);
|
|
537
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
538
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
539
|
+
/* harmony export */ });
|
|
540
|
+
/*
|
|
541
|
+
ES6 compatible port of CryptoJS - encoding
|
|
278
542
|
|
|
543
|
+
Source: https://github.com/brix/crypto-js
|
|
544
|
+
LICENSE: MIT
|
|
545
|
+
*/
|
|
546
|
+
const enc = {
|
|
547
|
+
Latin1: {
|
|
548
|
+
stringify: wordArray => {
|
|
549
|
+
// Shortcuts
|
|
550
|
+
let words = wordArray.words;
|
|
551
|
+
let sigBytes = wordArray.sigBytes;
|
|
552
|
+
let latin1Chars = [],
|
|
553
|
+
i,
|
|
554
|
+
bite;
|
|
279
555
|
|
|
280
|
-
|
|
556
|
+
// Convert
|
|
557
|
+
for (i = 0; i < sigBytes; i++) {
|
|
558
|
+
bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 0xff;
|
|
559
|
+
latin1Chars.push(String.fromCharCode(bite));
|
|
560
|
+
}
|
|
561
|
+
return latin1Chars.join('');
|
|
562
|
+
}
|
|
563
|
+
},
|
|
564
|
+
_Utf8: {
|
|
565
|
+
stringify: wordArray => {
|
|
566
|
+
try {
|
|
567
|
+
return decodeURIComponent(escape(enc.Latin1.stringify(wordArray)));
|
|
568
|
+
} catch (err) {
|
|
569
|
+
throw new Error('Malformed UTF-8 data', err);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (enc);
|
|
281
575
|
|
|
282
|
-
}
|
|
576
|
+
/***/ },
|
|
577
|
+
|
|
578
|
+
/***/ "./src/utils.js"
|
|
579
|
+
/*!**********************!*\
|
|
580
|
+
!*** ./src/utils.js ***!
|
|
581
|
+
\**********************/
|
|
582
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
583
|
+
|
|
584
|
+
"use strict";
|
|
585
|
+
__webpack_require__.r(__webpack_exports__);
|
|
586
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
587
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
588
|
+
/* harmony export */ });
|
|
589
|
+
/* harmony import */ var crypto_js_pbkdf2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! crypto-js/pbkdf2 */ "./node_modules/crypto-js/pbkdf2.js");
|
|
590
|
+
/* harmony import */ var crypto_js_pbkdf2__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(crypto_js_pbkdf2__WEBPACK_IMPORTED_MODULE_0__);
|
|
591
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants */ "./src/constants.js");
|
|
592
|
+
/* harmony import */ var _WordArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./WordArray */ "./src/WordArray.js");
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
const utils = {
|
|
597
|
+
is: key => !!key,
|
|
598
|
+
warn: (reason = _constants__WEBPACK_IMPORTED_MODULE_1__["default"].WarningEnum.DEFAULT_TEXT) => {
|
|
599
|
+
console.warn(_constants__WEBPACK_IMPORTED_MODULE_1__["default"].WarningTypes[reason]);
|
|
600
|
+
},
|
|
601
|
+
generateSecretKey: () => {
|
|
602
|
+
const salt = _WordArray__WEBPACK_IMPORTED_MODULE_2__["default"].random(128 / 8);
|
|
603
|
+
const key128Bits = crypto_js_pbkdf2__WEBPACK_IMPORTED_MODULE_0___default()(_constants__WEBPACK_IMPORTED_MODULE_1__["default"].secretPhrase, salt, {
|
|
604
|
+
keySize: 128 / 32
|
|
605
|
+
});
|
|
606
|
+
return key128Bits.toString();
|
|
607
|
+
},
|
|
608
|
+
getObjectFromKey: (data = [], key) => {
|
|
609
|
+
return data.find(item => item.k === key) || {};
|
|
610
|
+
},
|
|
611
|
+
extractKeyNames: ({
|
|
612
|
+
keys = []
|
|
613
|
+
} = {}) => {
|
|
614
|
+
return keys.map(({
|
|
615
|
+
k
|
|
616
|
+
}) => k);
|
|
617
|
+
},
|
|
618
|
+
isKeyPresent: (allKeys = [], key) => {
|
|
619
|
+
return allKeys.some(item => String(item.k) === String(key));
|
|
620
|
+
},
|
|
621
|
+
removeFromKeysList: (allKeys = [], key) => {
|
|
622
|
+
const index = allKeys.findIndex(item => item.k === key);
|
|
623
|
+
if (index !== -1) {
|
|
624
|
+
allKeys.splice(index, 1);
|
|
625
|
+
}
|
|
626
|
+
return index;
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (utils);
|
|
283
630
|
|
|
284
631
|
/***/ },
|
|
285
632
|
|
|
286
|
-
/***/ "./node_modules/crypto-js/
|
|
287
|
-
|
|
288
|
-
!*** ./node_modules/crypto-js/
|
|
289
|
-
|
|
633
|
+
/***/ "./node_modules/crypto-js/aes.js"
|
|
634
|
+
/*!***************************************!*\
|
|
635
|
+
!*** ./node_modules/crypto-js/aes.js ***!
|
|
636
|
+
\***************************************/
|
|
290
637
|
(module, exports, __webpack_require__) {
|
|
291
638
|
|
|
292
639
|
;(function (root, factory, undef) {
|
|
293
640
|
if (true) {
|
|
294
641
|
// CommonJS
|
|
295
|
-
module.exports = exports = factory(__webpack_require__(/*! ./core */ "./node_modules/crypto-js/core.js"), __webpack_require__(/*! ./evpkdf */ "./node_modules/crypto-js/evpkdf.js"));
|
|
642
|
+
module.exports = exports = factory(__webpack_require__(/*! ./core */ "./node_modules/crypto-js/core.js"), __webpack_require__(/*! ./enc-base64 */ "./node_modules/crypto-js/enc-base64.js"), __webpack_require__(/*! ./md5 */ "./node_modules/crypto-js/md5.js"), __webpack_require__(/*! ./evpkdf */ "./node_modules/crypto-js/evpkdf.js"), __webpack_require__(/*! ./cipher-core */ "./node_modules/crypto-js/cipher-core.js"));
|
|
296
643
|
}
|
|
297
644
|
else // removed by dead control flow
|
|
298
645
|
{}
|
|
299
646
|
}(this, function (CryptoJS) {
|
|
300
647
|
|
|
301
|
-
|
|
302
|
-
* Cipher core components.
|
|
303
|
-
*/
|
|
304
|
-
CryptoJS.lib.Cipher || (function (undefined) {
|
|
648
|
+
(function () {
|
|
305
649
|
// Shortcuts
|
|
306
650
|
var C = CryptoJS;
|
|
307
651
|
var C_lib = C.lib;
|
|
308
|
-
var
|
|
309
|
-
var WordArray = C_lib.WordArray;
|
|
310
|
-
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
|
|
311
|
-
var C_enc = C.enc;
|
|
312
|
-
var Utf8 = C_enc.Utf8;
|
|
313
|
-
var Base64 = C_enc.Base64;
|
|
652
|
+
var BlockCipher = C_lib.BlockCipher;
|
|
314
653
|
var C_algo = C.algo;
|
|
315
|
-
|
|
654
|
+
|
|
655
|
+
// Lookup tables
|
|
656
|
+
var SBOX = [];
|
|
657
|
+
var INV_SBOX = [];
|
|
658
|
+
var SUB_MIX_0 = [];
|
|
659
|
+
var SUB_MIX_1 = [];
|
|
660
|
+
var SUB_MIX_2 = [];
|
|
661
|
+
var SUB_MIX_3 = [];
|
|
662
|
+
var INV_SUB_MIX_0 = [];
|
|
663
|
+
var INV_SUB_MIX_1 = [];
|
|
664
|
+
var INV_SUB_MIX_2 = [];
|
|
665
|
+
var INV_SUB_MIX_3 = [];
|
|
666
|
+
|
|
667
|
+
// Compute lookup tables
|
|
668
|
+
(function () {
|
|
669
|
+
// Compute double table
|
|
670
|
+
var d = [];
|
|
671
|
+
for (var i = 0; i < 256; i++) {
|
|
672
|
+
if (i < 128) {
|
|
673
|
+
d[i] = i << 1;
|
|
674
|
+
} else {
|
|
675
|
+
d[i] = (i << 1) ^ 0x11b;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
// Walk GF(2^8)
|
|
680
|
+
var x = 0;
|
|
681
|
+
var xi = 0;
|
|
682
|
+
for (var i = 0; i < 256; i++) {
|
|
683
|
+
// Compute sbox
|
|
684
|
+
var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
|
|
685
|
+
sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
|
|
686
|
+
SBOX[x] = sx;
|
|
687
|
+
INV_SBOX[sx] = x;
|
|
688
|
+
|
|
689
|
+
// Compute multiplication
|
|
690
|
+
var x2 = d[x];
|
|
691
|
+
var x4 = d[x2];
|
|
692
|
+
var x8 = d[x4];
|
|
693
|
+
|
|
694
|
+
// Compute sub bytes, mix columns tables
|
|
695
|
+
var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
|
|
696
|
+
SUB_MIX_0[x] = (t << 24) | (t >>> 8);
|
|
697
|
+
SUB_MIX_1[x] = (t << 16) | (t >>> 16);
|
|
698
|
+
SUB_MIX_2[x] = (t << 8) | (t >>> 24);
|
|
699
|
+
SUB_MIX_3[x] = t;
|
|
700
|
+
|
|
701
|
+
// Compute inv sub bytes, inv mix columns tables
|
|
702
|
+
var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
|
|
703
|
+
INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
|
|
704
|
+
INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
|
|
705
|
+
INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
|
|
706
|
+
INV_SUB_MIX_3[sx] = t;
|
|
707
|
+
|
|
708
|
+
// Compute next counter
|
|
709
|
+
if (!x) {
|
|
710
|
+
x = xi = 1;
|
|
711
|
+
} else {
|
|
712
|
+
x = x2 ^ d[d[d[x8 ^ x2]]];
|
|
713
|
+
xi ^= d[d[xi]];
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}());
|
|
717
|
+
|
|
718
|
+
// Precomputed Rcon lookup
|
|
719
|
+
var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* AES block cipher algorithm.
|
|
723
|
+
*/
|
|
724
|
+
var AES = C_algo.AES = BlockCipher.extend({
|
|
725
|
+
_doReset: function () {
|
|
726
|
+
var t;
|
|
727
|
+
|
|
728
|
+
// Skip reset of nRounds has been set before and key did not change
|
|
729
|
+
if (this._nRounds && this._keyPriorReset === this._key) {
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
// Shortcuts
|
|
734
|
+
var key = this._keyPriorReset = this._key;
|
|
735
|
+
var keyWords = key.words;
|
|
736
|
+
var keySize = key.sigBytes / 4;
|
|
737
|
+
|
|
738
|
+
// Compute number of rounds
|
|
739
|
+
var nRounds = this._nRounds = keySize + 6;
|
|
740
|
+
|
|
741
|
+
// Compute number of key schedule rows
|
|
742
|
+
var ksRows = (nRounds + 1) * 4;
|
|
743
|
+
|
|
744
|
+
// Compute key schedule
|
|
745
|
+
var keySchedule = this._keySchedule = [];
|
|
746
|
+
for (var ksRow = 0; ksRow < ksRows; ksRow++) {
|
|
747
|
+
if (ksRow < keySize) {
|
|
748
|
+
keySchedule[ksRow] = keyWords[ksRow];
|
|
749
|
+
} else {
|
|
750
|
+
t = keySchedule[ksRow - 1];
|
|
751
|
+
|
|
752
|
+
if (!(ksRow % keySize)) {
|
|
753
|
+
// Rot word
|
|
754
|
+
t = (t << 8) | (t >>> 24);
|
|
755
|
+
|
|
756
|
+
// Sub word
|
|
757
|
+
t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
|
|
758
|
+
|
|
759
|
+
// Mix Rcon
|
|
760
|
+
t ^= RCON[(ksRow / keySize) | 0] << 24;
|
|
761
|
+
} else if (keySize > 6 && ksRow % keySize == 4) {
|
|
762
|
+
// Sub word
|
|
763
|
+
t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
// Compute inv key schedule
|
|
771
|
+
var invKeySchedule = this._invKeySchedule = [];
|
|
772
|
+
for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
|
|
773
|
+
var ksRow = ksRows - invKsRow;
|
|
774
|
+
|
|
775
|
+
if (invKsRow % 4) {
|
|
776
|
+
var t = keySchedule[ksRow];
|
|
777
|
+
} else {
|
|
778
|
+
var t = keySchedule[ksRow - 4];
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
if (invKsRow < 4 || ksRow <= 4) {
|
|
782
|
+
invKeySchedule[invKsRow] = t;
|
|
783
|
+
} else {
|
|
784
|
+
invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
|
|
785
|
+
INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
},
|
|
789
|
+
|
|
790
|
+
encryptBlock: function (M, offset) {
|
|
791
|
+
this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
|
|
792
|
+
},
|
|
793
|
+
|
|
794
|
+
decryptBlock: function (M, offset) {
|
|
795
|
+
// Swap 2nd and 4th rows
|
|
796
|
+
var t = M[offset + 1];
|
|
797
|
+
M[offset + 1] = M[offset + 3];
|
|
798
|
+
M[offset + 3] = t;
|
|
799
|
+
|
|
800
|
+
this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
|
|
801
|
+
|
|
802
|
+
// Inv swap 2nd and 4th rows
|
|
803
|
+
var t = M[offset + 1];
|
|
804
|
+
M[offset + 1] = M[offset + 3];
|
|
805
|
+
M[offset + 3] = t;
|
|
806
|
+
},
|
|
807
|
+
|
|
808
|
+
_doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
|
|
809
|
+
// Shortcut
|
|
810
|
+
var nRounds = this._nRounds;
|
|
811
|
+
|
|
812
|
+
// Get input, add round key
|
|
813
|
+
var s0 = M[offset] ^ keySchedule[0];
|
|
814
|
+
var s1 = M[offset + 1] ^ keySchedule[1];
|
|
815
|
+
var s2 = M[offset + 2] ^ keySchedule[2];
|
|
816
|
+
var s3 = M[offset + 3] ^ keySchedule[3];
|
|
817
|
+
|
|
818
|
+
// Key schedule row counter
|
|
819
|
+
var ksRow = 4;
|
|
820
|
+
|
|
821
|
+
// Rounds
|
|
822
|
+
for (var round = 1; round < nRounds; round++) {
|
|
823
|
+
// Shift rows, sub bytes, mix columns, add round key
|
|
824
|
+
var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
|
|
825
|
+
var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
|
|
826
|
+
var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
|
|
827
|
+
var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
|
|
828
|
+
|
|
829
|
+
// Update state
|
|
830
|
+
s0 = t0;
|
|
831
|
+
s1 = t1;
|
|
832
|
+
s2 = t2;
|
|
833
|
+
s3 = t3;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
// Shift rows, sub bytes, add round key
|
|
837
|
+
var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
|
|
838
|
+
var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
|
|
839
|
+
var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
|
|
840
|
+
var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
|
|
841
|
+
|
|
842
|
+
// Set output
|
|
843
|
+
M[offset] = t0;
|
|
844
|
+
M[offset + 1] = t1;
|
|
845
|
+
M[offset + 2] = t2;
|
|
846
|
+
M[offset + 3] = t3;
|
|
847
|
+
},
|
|
848
|
+
|
|
849
|
+
keySize: 256/32
|
|
850
|
+
});
|
|
851
|
+
|
|
852
|
+
/**
|
|
853
|
+
* Shortcut functions to the cipher's object interface.
|
|
854
|
+
*
|
|
855
|
+
* @example
|
|
856
|
+
*
|
|
857
|
+
* var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
|
|
858
|
+
* var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
|
|
859
|
+
*/
|
|
860
|
+
C.AES = BlockCipher._createHelper(AES);
|
|
861
|
+
}());
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
return CryptoJS.AES;
|
|
865
|
+
|
|
866
|
+
}));
|
|
867
|
+
|
|
868
|
+
/***/ },
|
|
869
|
+
|
|
870
|
+
/***/ "./node_modules/crypto-js/cipher-core.js"
|
|
871
|
+
/*!***********************************************!*\
|
|
872
|
+
!*** ./node_modules/crypto-js/cipher-core.js ***!
|
|
873
|
+
\***********************************************/
|
|
874
|
+
(module, exports, __webpack_require__) {
|
|
875
|
+
|
|
876
|
+
;(function (root, factory, undef) {
|
|
877
|
+
if (true) {
|
|
878
|
+
// CommonJS
|
|
879
|
+
module.exports = exports = factory(__webpack_require__(/*! ./core */ "./node_modules/crypto-js/core.js"), __webpack_require__(/*! ./evpkdf */ "./node_modules/crypto-js/evpkdf.js"));
|
|
880
|
+
}
|
|
881
|
+
else // removed by dead control flow
|
|
882
|
+
{}
|
|
883
|
+
}(this, function (CryptoJS) {
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Cipher core components.
|
|
887
|
+
*/
|
|
888
|
+
CryptoJS.lib.Cipher || (function (undefined) {
|
|
889
|
+
// Shortcuts
|
|
890
|
+
var C = CryptoJS;
|
|
891
|
+
var C_lib = C.lib;
|
|
892
|
+
var Base = C_lib.Base;
|
|
893
|
+
var WordArray = C_lib.WordArray;
|
|
894
|
+
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
|
|
895
|
+
var C_enc = C.enc;
|
|
896
|
+
var Utf8 = C_enc.Utf8;
|
|
897
|
+
var Base64 = C_enc.Base64;
|
|
898
|
+
var C_algo = C.algo;
|
|
899
|
+
var EvpKDF = C_algo.EvpKDF;
|
|
316
900
|
|
|
317
901
|
/**
|
|
318
902
|
* Abstract base cipher template.
|
|
@@ -4029,1375 +4613,791 @@ return /******/ (() => { // webpackBootstrap
|
|
|
4029
4613
|
0x168: 0x401,
|
|
4030
4614
|
0x178: 0x2100400,
|
|
4031
4615
|
0x188: 0x2000001,
|
|
4032
|
-
0x198: 0x2100000,
|
|
4033
|
-
0x1a8: 0x0,
|
|
4034
|
-
0x1b8: 0x2100401,
|
|
4035
|
-
0x1c8: 0x100401,
|
|
4036
|
-
0x1d8: 0x400,
|
|
4037
|
-
0x1e8: 0x2000400,
|
|
4038
|
-
0x1f8: 0x100001
|
|
4039
|
-
},
|
|
4040
|
-
{
|
|
4041
|
-
0x0: 0x8000820,
|
|
4042
|
-
0x1: 0x20000,
|
|
4043
|
-
0x2: 0x8000000,
|
|
4044
|
-
0x3: 0x20,
|
|
4045
|
-
0x4: 0x20020,
|
|
4046
|
-
0x5: 0x8020820,
|
|
4047
|
-
0x6: 0x8020800,
|
|
4048
|
-
0x7: 0x800,
|
|
4049
|
-
0x8: 0x8020000,
|
|
4050
|
-
0x9: 0x8000800,
|
|
4051
|
-
0xa: 0x20800,
|
|
4052
|
-
0xb: 0x8020020,
|
|
4053
|
-
0xc: 0x820,
|
|
4054
|
-
0xd: 0x0,
|
|
4055
|
-
0xe: 0x8000020,
|
|
4056
|
-
0xf: 0x20820,
|
|
4057
|
-
0x80000000: 0x800,
|
|
4058
|
-
0x80000001: 0x8020820,
|
|
4059
|
-
0x80000002: 0x8000820,
|
|
4060
|
-
0x80000003: 0x8000000,
|
|
4061
|
-
0x80000004: 0x8020000,
|
|
4062
|
-
0x80000005: 0x20800,
|
|
4063
|
-
0x80000006: 0x20820,
|
|
4064
|
-
0x80000007: 0x20,
|
|
4065
|
-
0x80000008: 0x8000020,
|
|
4066
|
-
0x80000009: 0x820,
|
|
4067
|
-
0x8000000a: 0x20020,
|
|
4068
|
-
0x8000000b: 0x8020800,
|
|
4069
|
-
0x8000000c: 0x0,
|
|
4070
|
-
0x8000000d: 0x8020020,
|
|
4071
|
-
0x8000000e: 0x8000800,
|
|
4072
|
-
0x8000000f: 0x20000,
|
|
4073
|
-
0x10: 0x20820,
|
|
4074
|
-
0x11: 0x8020800,
|
|
4075
|
-
0x12: 0x20,
|
|
4076
|
-
0x13: 0x800,
|
|
4077
|
-
0x14: 0x8000800,
|
|
4078
|
-
0x15: 0x8000020,
|
|
4079
|
-
0x16: 0x8020020,
|
|
4080
|
-
0x17: 0x20000,
|
|
4081
|
-
0x18: 0x0,
|
|
4082
|
-
0x19: 0x20020,
|
|
4083
|
-
0x1a: 0x8020000,
|
|
4084
|
-
0x1b: 0x8000820,
|
|
4085
|
-
0x1c: 0x8020820,
|
|
4086
|
-
0x1d: 0x20800,
|
|
4087
|
-
0x1e: 0x820,
|
|
4088
|
-
0x1f: 0x8000000,
|
|
4089
|
-
0x80000010: 0x20000,
|
|
4090
|
-
0x80000011: 0x800,
|
|
4091
|
-
0x80000012: 0x8020020,
|
|
4092
|
-
0x80000013: 0x20820,
|
|
4093
|
-
0x80000014: 0x20,
|
|
4094
|
-
0x80000015: 0x8020000,
|
|
4095
|
-
0x80000016: 0x8000000,
|
|
4096
|
-
0x80000017: 0x8000820,
|
|
4097
|
-
0x80000018: 0x8020820,
|
|
4098
|
-
0x80000019: 0x8000020,
|
|
4099
|
-
0x8000001a: 0x8000800,
|
|
4100
|
-
0x8000001b: 0x0,
|
|
4101
|
-
0x8000001c: 0x20800,
|
|
4102
|
-
0x8000001d: 0x820,
|
|
4103
|
-
0x8000001e: 0x20020,
|
|
4104
|
-
0x8000001f: 0x8020800
|
|
4105
|
-
}
|
|
4106
|
-
];
|
|
4107
|
-
|
|
4108
|
-
// Masks that select the SBOX input
|
|
4109
|
-
var SBOX_MASK = [
|
|
4110
|
-
0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
|
|
4111
|
-
0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
|
|
4112
|
-
];
|
|
4113
|
-
|
|
4114
|
-
/**
|
|
4115
|
-
* DES block cipher algorithm.
|
|
4116
|
-
*/
|
|
4117
|
-
var DES = C_algo.DES = BlockCipher.extend({
|
|
4118
|
-
_doReset: function () {
|
|
4119
|
-
// Shortcuts
|
|
4120
|
-
var key = this._key;
|
|
4121
|
-
var keyWords = key.words;
|
|
4122
|
-
|
|
4123
|
-
// Select 56 bits according to PC1
|
|
4124
|
-
var keyBits = [];
|
|
4125
|
-
for (var i = 0; i < 56; i++) {
|
|
4126
|
-
var keyBitPos = PC1[i] - 1;
|
|
4127
|
-
keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
|
|
4128
|
-
}
|
|
4129
|
-
|
|
4130
|
-
// Assemble 16 subkeys
|
|
4131
|
-
var subKeys = this._subKeys = [];
|
|
4132
|
-
for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
|
|
4133
|
-
// Create subkey
|
|
4134
|
-
var subKey = subKeys[nSubKey] = [];
|
|
4135
|
-
|
|
4136
|
-
// Shortcut
|
|
4137
|
-
var bitShift = BIT_SHIFTS[nSubKey];
|
|
4138
|
-
|
|
4139
|
-
// Select 48 bits according to PC2
|
|
4140
|
-
for (var i = 0; i < 24; i++) {
|
|
4141
|
-
// Select from the left 28 key bits
|
|
4142
|
-
subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
|
|
4143
|
-
|
|
4144
|
-
// Select from the right 28 key bits
|
|
4145
|
-
subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
|
|
4146
|
-
}
|
|
4147
|
-
|
|
4148
|
-
// Since each subkey is applied to an expanded 32-bit input,
|
|
4149
|
-
// the subkey can be broken into 8 values scaled to 32-bits,
|
|
4150
|
-
// which allows the key to be used without expansion
|
|
4151
|
-
subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
|
|
4152
|
-
for (var i = 1; i < 7; i++) {
|
|
4153
|
-
subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
|
|
4154
|
-
}
|
|
4155
|
-
subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
|
|
4156
|
-
}
|
|
4157
|
-
|
|
4158
|
-
// Compute inverse subkeys
|
|
4159
|
-
var invSubKeys = this._invSubKeys = [];
|
|
4160
|
-
for (var i = 0; i < 16; i++) {
|
|
4161
|
-
invSubKeys[i] = subKeys[15 - i];
|
|
4162
|
-
}
|
|
4163
|
-
},
|
|
4164
|
-
|
|
4165
|
-
encryptBlock: function (M, offset) {
|
|
4166
|
-
this._doCryptBlock(M, offset, this._subKeys);
|
|
4167
|
-
},
|
|
4168
|
-
|
|
4169
|
-
decryptBlock: function (M, offset) {
|
|
4170
|
-
this._doCryptBlock(M, offset, this._invSubKeys);
|
|
4171
|
-
},
|
|
4172
|
-
|
|
4173
|
-
_doCryptBlock: function (M, offset, subKeys) {
|
|
4174
|
-
// Get input
|
|
4175
|
-
this._lBlock = M[offset];
|
|
4176
|
-
this._rBlock = M[offset + 1];
|
|
4177
|
-
|
|
4178
|
-
// Initial permutation
|
|
4179
|
-
exchangeLR.call(this, 4, 0x0f0f0f0f);
|
|
4180
|
-
exchangeLR.call(this, 16, 0x0000ffff);
|
|
4181
|
-
exchangeRL.call(this, 2, 0x33333333);
|
|
4182
|
-
exchangeRL.call(this, 8, 0x00ff00ff);
|
|
4183
|
-
exchangeLR.call(this, 1, 0x55555555);
|
|
4184
|
-
|
|
4185
|
-
// Rounds
|
|
4186
|
-
for (var round = 0; round < 16; round++) {
|
|
4187
|
-
// Shortcuts
|
|
4188
|
-
var subKey = subKeys[round];
|
|
4189
|
-
var lBlock = this._lBlock;
|
|
4190
|
-
var rBlock = this._rBlock;
|
|
4191
|
-
|
|
4192
|
-
// Feistel function
|
|
4193
|
-
var f = 0;
|
|
4194
|
-
for (var i = 0; i < 8; i++) {
|
|
4195
|
-
f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
|
|
4196
|
-
}
|
|
4197
|
-
this._lBlock = rBlock;
|
|
4198
|
-
this._rBlock = lBlock ^ f;
|
|
4199
|
-
}
|
|
4200
|
-
|
|
4201
|
-
// Undo swap from last round
|
|
4202
|
-
var t = this._lBlock;
|
|
4203
|
-
this._lBlock = this._rBlock;
|
|
4204
|
-
this._rBlock = t;
|
|
4205
|
-
|
|
4206
|
-
// Final permutation
|
|
4207
|
-
exchangeLR.call(this, 1, 0x55555555);
|
|
4208
|
-
exchangeRL.call(this, 8, 0x00ff00ff);
|
|
4209
|
-
exchangeRL.call(this, 2, 0x33333333);
|
|
4210
|
-
exchangeLR.call(this, 16, 0x0000ffff);
|
|
4211
|
-
exchangeLR.call(this, 4, 0x0f0f0f0f);
|
|
4212
|
-
|
|
4213
|
-
// Set output
|
|
4214
|
-
M[offset] = this._lBlock;
|
|
4215
|
-
M[offset + 1] = this._rBlock;
|
|
4216
|
-
},
|
|
4217
|
-
|
|
4218
|
-
keySize: 64/32,
|
|
4219
|
-
|
|
4220
|
-
ivSize: 64/32,
|
|
4221
|
-
|
|
4222
|
-
blockSize: 64/32
|
|
4223
|
-
});
|
|
4224
|
-
|
|
4225
|
-
// Swap bits across the left and right words
|
|
4226
|
-
function exchangeLR(offset, mask) {
|
|
4227
|
-
var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
|
|
4228
|
-
this._rBlock ^= t;
|
|
4229
|
-
this._lBlock ^= t << offset;
|
|
4230
|
-
}
|
|
4231
|
-
|
|
4232
|
-
function exchangeRL(offset, mask) {
|
|
4233
|
-
var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
|
|
4234
|
-
this._lBlock ^= t;
|
|
4235
|
-
this._rBlock ^= t << offset;
|
|
4236
|
-
}
|
|
4237
|
-
|
|
4238
|
-
/**
|
|
4239
|
-
* Shortcut functions to the cipher's object interface.
|
|
4240
|
-
*
|
|
4241
|
-
* @example
|
|
4242
|
-
*
|
|
4243
|
-
* var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
|
|
4244
|
-
* var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg);
|
|
4245
|
-
*/
|
|
4246
|
-
C.DES = BlockCipher._createHelper(DES);
|
|
4247
|
-
|
|
4248
|
-
/**
|
|
4249
|
-
* Triple-DES block cipher algorithm.
|
|
4250
|
-
*/
|
|
4251
|
-
var TripleDES = C_algo.TripleDES = BlockCipher.extend({
|
|
4252
|
-
_doReset: function () {
|
|
4253
|
-
// Shortcuts
|
|
4254
|
-
var key = this._key;
|
|
4255
|
-
var keyWords = key.words;
|
|
4256
|
-
// Make sure the key length is valid (64, 128 or >= 192 bit)
|
|
4257
|
-
if (keyWords.length !== 2 && keyWords.length !== 4 && keyWords.length < 6) {
|
|
4258
|
-
throw new Error('Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.');
|
|
4259
|
-
}
|
|
4260
|
-
|
|
4261
|
-
// Extend the key according to the keying options defined in 3DES standard
|
|
4262
|
-
var key1 = keyWords.slice(0, 2);
|
|
4263
|
-
var key2 = keyWords.length < 4 ? keyWords.slice(0, 2) : keyWords.slice(2, 4);
|
|
4264
|
-
var key3 = keyWords.length < 6 ? keyWords.slice(0, 2) : keyWords.slice(4, 6);
|
|
4265
|
-
|
|
4266
|
-
// Create DES instances
|
|
4267
|
-
this._des1 = DES.createEncryptor(WordArray.create(key1));
|
|
4268
|
-
this._des2 = DES.createEncryptor(WordArray.create(key2));
|
|
4269
|
-
this._des3 = DES.createEncryptor(WordArray.create(key3));
|
|
4270
|
-
},
|
|
4271
|
-
|
|
4272
|
-
encryptBlock: function (M, offset) {
|
|
4273
|
-
this._des1.encryptBlock(M, offset);
|
|
4274
|
-
this._des2.decryptBlock(M, offset);
|
|
4275
|
-
this._des3.encryptBlock(M, offset);
|
|
4276
|
-
},
|
|
4277
|
-
|
|
4278
|
-
decryptBlock: function (M, offset) {
|
|
4279
|
-
this._des3.decryptBlock(M, offset);
|
|
4280
|
-
this._des2.encryptBlock(M, offset);
|
|
4281
|
-
this._des1.decryptBlock(M, offset);
|
|
4282
|
-
},
|
|
4283
|
-
|
|
4284
|
-
keySize: 192/32,
|
|
4285
|
-
|
|
4286
|
-
ivSize: 64/32,
|
|
4287
|
-
|
|
4288
|
-
blockSize: 64/32
|
|
4289
|
-
});
|
|
4290
|
-
|
|
4291
|
-
/**
|
|
4292
|
-
* Shortcut functions to the cipher's object interface.
|
|
4293
|
-
*
|
|
4294
|
-
* @example
|
|
4295
|
-
*
|
|
4296
|
-
* var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
|
|
4297
|
-
* var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
|
|
4298
|
-
*/
|
|
4299
|
-
C.TripleDES = BlockCipher._createHelper(TripleDES);
|
|
4300
|
-
}());
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
return CryptoJS.TripleDES;
|
|
4304
|
-
|
|
4305
|
-
}));
|
|
4306
|
-
|
|
4307
|
-
/***/ },
|
|
4308
|
-
|
|
4309
|
-
/***/ "./node_modules/lz-string/libs/lz-string.js"
|
|
4310
|
-
/*!**************************************************!*\
|
|
4311
|
-
!*** ./node_modules/lz-string/libs/lz-string.js ***!
|
|
4312
|
-
\**************************************************/
|
|
4313
|
-
(module, exports, __webpack_require__) {
|
|
4314
|
-
|
|
4315
|
-
var __WEBPACK_AMD_DEFINE_RESULT__;// Copyright (c) 2013 Pieroxy <pieroxy@pieroxy.net>
|
|
4316
|
-
// This work is free. You can redistribute it and/or modify it
|
|
4317
|
-
// under the terms of the WTFPL, Version 2
|
|
4318
|
-
// For more information see LICENSE.txt or http://www.wtfpl.net/
|
|
4319
|
-
//
|
|
4320
|
-
// For more information, the home page:
|
|
4321
|
-
// http://pieroxy.net/blog/pages/lz-string/testing.html
|
|
4322
|
-
//
|
|
4323
|
-
// LZ-based compression algorithm, version 1.4.5
|
|
4324
|
-
var LZString = (function() {
|
|
4325
|
-
|
|
4326
|
-
// private property
|
|
4327
|
-
var f = String.fromCharCode;
|
|
4328
|
-
var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
4329
|
-
var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
|
|
4330
|
-
var baseReverseDic = {};
|
|
4331
|
-
|
|
4332
|
-
function getBaseValue(alphabet, character) {
|
|
4333
|
-
if (!baseReverseDic[alphabet]) {
|
|
4334
|
-
baseReverseDic[alphabet] = {};
|
|
4335
|
-
for (var i=0 ; i<alphabet.length ; i++) {
|
|
4336
|
-
baseReverseDic[alphabet][alphabet.charAt(i)] = i;
|
|
4337
|
-
}
|
|
4338
|
-
}
|
|
4339
|
-
return baseReverseDic[alphabet][character];
|
|
4340
|
-
}
|
|
4341
|
-
|
|
4342
|
-
var LZString = {
|
|
4343
|
-
compressToBase64 : function (input) {
|
|
4344
|
-
if (input == null) return "";
|
|
4345
|
-
var res = LZString._compress(input, 6, function(a){return keyStrBase64.charAt(a);});
|
|
4346
|
-
switch (res.length % 4) { // To produce valid Base64
|
|
4347
|
-
default: // When could this happen ?
|
|
4348
|
-
case 0 : return res;
|
|
4349
|
-
case 1 : return res+"===";
|
|
4350
|
-
case 2 : return res+"==";
|
|
4351
|
-
case 3 : return res+"=";
|
|
4352
|
-
}
|
|
4353
|
-
},
|
|
4354
|
-
|
|
4355
|
-
decompressFromBase64 : function (input) {
|
|
4356
|
-
if (input == null) return "";
|
|
4357
|
-
if (input == "") return null;
|
|
4358
|
-
return LZString._decompress(input.length, 32, function(index) { return getBaseValue(keyStrBase64, input.charAt(index)); });
|
|
4359
|
-
},
|
|
4360
|
-
|
|
4361
|
-
compressToUTF16 : function (input) {
|
|
4362
|
-
if (input == null) return "";
|
|
4363
|
-
return LZString._compress(input, 15, function(a){return f(a+32);}) + " ";
|
|
4364
|
-
},
|
|
4365
|
-
|
|
4366
|
-
decompressFromUTF16: function (compressed) {
|
|
4367
|
-
if (compressed == null) return "";
|
|
4368
|
-
if (compressed == "") return null;
|
|
4369
|
-
return LZString._decompress(compressed.length, 16384, function(index) { return compressed.charCodeAt(index) - 32; });
|
|
4370
|
-
},
|
|
4371
|
-
|
|
4372
|
-
//compress into uint8array (UCS-2 big endian format)
|
|
4373
|
-
compressToUint8Array: function (uncompressed) {
|
|
4374
|
-
var compressed = LZString.compress(uncompressed);
|
|
4375
|
-
var buf=new Uint8Array(compressed.length*2); // 2 bytes per character
|
|
4376
|
-
|
|
4377
|
-
for (var i=0, TotalLen=compressed.length; i<TotalLen; i++) {
|
|
4378
|
-
var current_value = compressed.charCodeAt(i);
|
|
4379
|
-
buf[i*2] = current_value >>> 8;
|
|
4380
|
-
buf[i*2+1] = current_value % 256;
|
|
4381
|
-
}
|
|
4382
|
-
return buf;
|
|
4383
|
-
},
|
|
4384
|
-
|
|
4385
|
-
//decompress from uint8array (UCS-2 big endian format)
|
|
4386
|
-
decompressFromUint8Array:function (compressed) {
|
|
4387
|
-
if (compressed===null || compressed===undefined){
|
|
4388
|
-
return LZString.decompress(compressed);
|
|
4389
|
-
} else {
|
|
4390
|
-
var buf=new Array(compressed.length/2); // 2 bytes per character
|
|
4391
|
-
for (var i=0, TotalLen=buf.length; i<TotalLen; i++) {
|
|
4392
|
-
buf[i]=compressed[i*2]*256+compressed[i*2+1];
|
|
4393
|
-
}
|
|
4394
|
-
|
|
4395
|
-
var result = [];
|
|
4396
|
-
buf.forEach(function (c) {
|
|
4397
|
-
result.push(f(c));
|
|
4398
|
-
});
|
|
4399
|
-
return LZString.decompress(result.join(''));
|
|
4400
|
-
|
|
4401
|
-
}
|
|
4402
|
-
|
|
4403
|
-
},
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
//compress into a string that is already URI encoded
|
|
4407
|
-
compressToEncodedURIComponent: function (input) {
|
|
4408
|
-
if (input == null) return "";
|
|
4409
|
-
return LZString._compress(input, 6, function(a){return keyStrUriSafe.charAt(a);});
|
|
4410
|
-
},
|
|
4411
|
-
|
|
4412
|
-
//decompress from an output of compressToEncodedURIComponent
|
|
4413
|
-
decompressFromEncodedURIComponent:function (input) {
|
|
4414
|
-
if (input == null) return "";
|
|
4415
|
-
if (input == "") return null;
|
|
4416
|
-
input = input.replace(/ /g, "+");
|
|
4417
|
-
return LZString._decompress(input.length, 32, function(index) { return getBaseValue(keyStrUriSafe, input.charAt(index)); });
|
|
4418
|
-
},
|
|
4419
|
-
|
|
4420
|
-
compress: function (uncompressed) {
|
|
4421
|
-
return LZString._compress(uncompressed, 16, function(a){return f(a);});
|
|
4422
|
-
},
|
|
4423
|
-
_compress: function (uncompressed, bitsPerChar, getCharFromInt) {
|
|
4424
|
-
if (uncompressed == null) return "";
|
|
4425
|
-
var i, value,
|
|
4426
|
-
context_dictionary= {},
|
|
4427
|
-
context_dictionaryToCreate= {},
|
|
4428
|
-
context_c="",
|
|
4429
|
-
context_wc="",
|
|
4430
|
-
context_w="",
|
|
4431
|
-
context_enlargeIn= 2, // Compensate for the first entry which should not count
|
|
4432
|
-
context_dictSize= 3,
|
|
4433
|
-
context_numBits= 2,
|
|
4434
|
-
context_data=[],
|
|
4435
|
-
context_data_val=0,
|
|
4436
|
-
context_data_position=0,
|
|
4437
|
-
ii;
|
|
4438
|
-
|
|
4439
|
-
for (ii = 0; ii < uncompressed.length; ii += 1) {
|
|
4440
|
-
context_c = uncompressed.charAt(ii);
|
|
4441
|
-
if (!Object.prototype.hasOwnProperty.call(context_dictionary,context_c)) {
|
|
4442
|
-
context_dictionary[context_c] = context_dictSize++;
|
|
4443
|
-
context_dictionaryToCreate[context_c] = true;
|
|
4444
|
-
}
|
|
4445
|
-
|
|
4446
|
-
context_wc = context_w + context_c;
|
|
4447
|
-
if (Object.prototype.hasOwnProperty.call(context_dictionary,context_wc)) {
|
|
4448
|
-
context_w = context_wc;
|
|
4449
|
-
} else {
|
|
4450
|
-
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate,context_w)) {
|
|
4451
|
-
if (context_w.charCodeAt(0)<256) {
|
|
4452
|
-
for (i=0 ; i<context_numBits ; i++) {
|
|
4453
|
-
context_data_val = (context_data_val << 1);
|
|
4454
|
-
if (context_data_position == bitsPerChar-1) {
|
|
4455
|
-
context_data_position = 0;
|
|
4456
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
4457
|
-
context_data_val = 0;
|
|
4458
|
-
} else {
|
|
4459
|
-
context_data_position++;
|
|
4460
|
-
}
|
|
4461
|
-
}
|
|
4462
|
-
value = context_w.charCodeAt(0);
|
|
4463
|
-
for (i=0 ; i<8 ; i++) {
|
|
4464
|
-
context_data_val = (context_data_val << 1) | (value&1);
|
|
4465
|
-
if (context_data_position == bitsPerChar-1) {
|
|
4466
|
-
context_data_position = 0;
|
|
4467
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
4468
|
-
context_data_val = 0;
|
|
4469
|
-
} else {
|
|
4470
|
-
context_data_position++;
|
|
4471
|
-
}
|
|
4472
|
-
value = value >> 1;
|
|
4473
|
-
}
|
|
4474
|
-
} else {
|
|
4475
|
-
value = 1;
|
|
4476
|
-
for (i=0 ; i<context_numBits ; i++) {
|
|
4477
|
-
context_data_val = (context_data_val << 1) | value;
|
|
4478
|
-
if (context_data_position ==bitsPerChar-1) {
|
|
4479
|
-
context_data_position = 0;
|
|
4480
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
4481
|
-
context_data_val = 0;
|
|
4482
|
-
} else {
|
|
4483
|
-
context_data_position++;
|
|
4484
|
-
}
|
|
4485
|
-
value = 0;
|
|
4486
|
-
}
|
|
4487
|
-
value = context_w.charCodeAt(0);
|
|
4488
|
-
for (i=0 ; i<16 ; i++) {
|
|
4489
|
-
context_data_val = (context_data_val << 1) | (value&1);
|
|
4490
|
-
if (context_data_position == bitsPerChar-1) {
|
|
4491
|
-
context_data_position = 0;
|
|
4492
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
4493
|
-
context_data_val = 0;
|
|
4494
|
-
} else {
|
|
4495
|
-
context_data_position++;
|
|
4496
|
-
}
|
|
4497
|
-
value = value >> 1;
|
|
4498
|
-
}
|
|
4499
|
-
}
|
|
4500
|
-
context_enlargeIn--;
|
|
4501
|
-
if (context_enlargeIn == 0) {
|
|
4502
|
-
context_enlargeIn = Math.pow(2, context_numBits);
|
|
4503
|
-
context_numBits++;
|
|
4504
|
-
}
|
|
4505
|
-
delete context_dictionaryToCreate[context_w];
|
|
4506
|
-
} else {
|
|
4507
|
-
value = context_dictionary[context_w];
|
|
4508
|
-
for (i=0 ; i<context_numBits ; i++) {
|
|
4509
|
-
context_data_val = (context_data_val << 1) | (value&1);
|
|
4510
|
-
if (context_data_position == bitsPerChar-1) {
|
|
4511
|
-
context_data_position = 0;
|
|
4512
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
4513
|
-
context_data_val = 0;
|
|
4514
|
-
} else {
|
|
4515
|
-
context_data_position++;
|
|
4516
|
-
}
|
|
4517
|
-
value = value >> 1;
|
|
4518
|
-
}
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
}
|
|
4522
|
-
context_enlargeIn--;
|
|
4523
|
-
if (context_enlargeIn == 0) {
|
|
4524
|
-
context_enlargeIn = Math.pow(2, context_numBits);
|
|
4525
|
-
context_numBits++;
|
|
4526
|
-
}
|
|
4527
|
-
// Add wc to the dictionary.
|
|
4528
|
-
context_dictionary[context_wc] = context_dictSize++;
|
|
4529
|
-
context_w = String(context_c);
|
|
4530
|
-
}
|
|
4531
|
-
}
|
|
4532
|
-
|
|
4533
|
-
// Output the code for w.
|
|
4534
|
-
if (context_w !== "") {
|
|
4535
|
-
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate,context_w)) {
|
|
4536
|
-
if (context_w.charCodeAt(0)<256) {
|
|
4537
|
-
for (i=0 ; i<context_numBits ; i++) {
|
|
4538
|
-
context_data_val = (context_data_val << 1);
|
|
4539
|
-
if (context_data_position == bitsPerChar-1) {
|
|
4540
|
-
context_data_position = 0;
|
|
4541
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
4542
|
-
context_data_val = 0;
|
|
4543
|
-
} else {
|
|
4544
|
-
context_data_position++;
|
|
4545
|
-
}
|
|
4546
|
-
}
|
|
4547
|
-
value = context_w.charCodeAt(0);
|
|
4548
|
-
for (i=0 ; i<8 ; i++) {
|
|
4549
|
-
context_data_val = (context_data_val << 1) | (value&1);
|
|
4550
|
-
if (context_data_position == bitsPerChar-1) {
|
|
4551
|
-
context_data_position = 0;
|
|
4552
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
4553
|
-
context_data_val = 0;
|
|
4554
|
-
} else {
|
|
4555
|
-
context_data_position++;
|
|
4556
|
-
}
|
|
4557
|
-
value = value >> 1;
|
|
4558
|
-
}
|
|
4559
|
-
} else {
|
|
4560
|
-
value = 1;
|
|
4561
|
-
for (i=0 ; i<context_numBits ; i++) {
|
|
4562
|
-
context_data_val = (context_data_val << 1) | value;
|
|
4563
|
-
if (context_data_position == bitsPerChar-1) {
|
|
4564
|
-
context_data_position = 0;
|
|
4565
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
4566
|
-
context_data_val = 0;
|
|
4567
|
-
} else {
|
|
4568
|
-
context_data_position++;
|
|
4569
|
-
}
|
|
4570
|
-
value = 0;
|
|
4571
|
-
}
|
|
4572
|
-
value = context_w.charCodeAt(0);
|
|
4573
|
-
for (i=0 ; i<16 ; i++) {
|
|
4574
|
-
context_data_val = (context_data_val << 1) | (value&1);
|
|
4575
|
-
if (context_data_position == bitsPerChar-1) {
|
|
4576
|
-
context_data_position = 0;
|
|
4577
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
4578
|
-
context_data_val = 0;
|
|
4579
|
-
} else {
|
|
4580
|
-
context_data_position++;
|
|
4581
|
-
}
|
|
4582
|
-
value = value >> 1;
|
|
4583
|
-
}
|
|
4584
|
-
}
|
|
4585
|
-
context_enlargeIn--;
|
|
4586
|
-
if (context_enlargeIn == 0) {
|
|
4587
|
-
context_enlargeIn = Math.pow(2, context_numBits);
|
|
4588
|
-
context_numBits++;
|
|
4589
|
-
}
|
|
4590
|
-
delete context_dictionaryToCreate[context_w];
|
|
4591
|
-
} else {
|
|
4592
|
-
value = context_dictionary[context_w];
|
|
4593
|
-
for (i=0 ; i<context_numBits ; i++) {
|
|
4594
|
-
context_data_val = (context_data_val << 1) | (value&1);
|
|
4595
|
-
if (context_data_position == bitsPerChar-1) {
|
|
4596
|
-
context_data_position = 0;
|
|
4597
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
4598
|
-
context_data_val = 0;
|
|
4599
|
-
} else {
|
|
4600
|
-
context_data_position++;
|
|
4601
|
-
}
|
|
4602
|
-
value = value >> 1;
|
|
4603
|
-
}
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
}
|
|
4607
|
-
context_enlargeIn--;
|
|
4608
|
-
if (context_enlargeIn == 0) {
|
|
4609
|
-
context_enlargeIn = Math.pow(2, context_numBits);
|
|
4610
|
-
context_numBits++;
|
|
4611
|
-
}
|
|
4612
|
-
}
|
|
4613
|
-
|
|
4614
|
-
// Mark the end of the stream
|
|
4615
|
-
value = 2;
|
|
4616
|
-
for (i=0 ; i<context_numBits ; i++) {
|
|
4617
|
-
context_data_val = (context_data_val << 1) | (value&1);
|
|
4618
|
-
if (context_data_position == bitsPerChar-1) {
|
|
4619
|
-
context_data_position = 0;
|
|
4620
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
4621
|
-
context_data_val = 0;
|
|
4622
|
-
} else {
|
|
4623
|
-
context_data_position++;
|
|
4624
|
-
}
|
|
4625
|
-
value = value >> 1;
|
|
4626
|
-
}
|
|
4627
|
-
|
|
4628
|
-
// Flush the last char
|
|
4629
|
-
while (true) {
|
|
4630
|
-
context_data_val = (context_data_val << 1);
|
|
4631
|
-
if (context_data_position == bitsPerChar-1) {
|
|
4632
|
-
context_data.push(getCharFromInt(context_data_val));
|
|
4633
|
-
break;
|
|
4634
|
-
}
|
|
4635
|
-
else context_data_position++;
|
|
4636
|
-
}
|
|
4637
|
-
return context_data.join('');
|
|
4638
|
-
},
|
|
4639
|
-
|
|
4640
|
-
decompress: function (compressed) {
|
|
4641
|
-
if (compressed == null) return "";
|
|
4642
|
-
if (compressed == "") return null;
|
|
4643
|
-
return LZString._decompress(compressed.length, 32768, function(index) { return compressed.charCodeAt(index); });
|
|
4644
|
-
},
|
|
4645
|
-
|
|
4646
|
-
_decompress: function (length, resetValue, getNextValue) {
|
|
4647
|
-
var dictionary = [],
|
|
4648
|
-
next,
|
|
4649
|
-
enlargeIn = 4,
|
|
4650
|
-
dictSize = 4,
|
|
4651
|
-
numBits = 3,
|
|
4652
|
-
entry = "",
|
|
4653
|
-
result = [],
|
|
4654
|
-
i,
|
|
4655
|
-
w,
|
|
4656
|
-
bits, resb, maxpower, power,
|
|
4657
|
-
c,
|
|
4658
|
-
data = {val:getNextValue(0), position:resetValue, index:1};
|
|
4659
|
-
|
|
4660
|
-
for (i = 0; i < 3; i += 1) {
|
|
4661
|
-
dictionary[i] = i;
|
|
4662
|
-
}
|
|
4663
|
-
|
|
4664
|
-
bits = 0;
|
|
4665
|
-
maxpower = Math.pow(2,2);
|
|
4666
|
-
power=1;
|
|
4667
|
-
while (power!=maxpower) {
|
|
4668
|
-
resb = data.val & data.position;
|
|
4669
|
-
data.position >>= 1;
|
|
4670
|
-
if (data.position == 0) {
|
|
4671
|
-
data.position = resetValue;
|
|
4672
|
-
data.val = getNextValue(data.index++);
|
|
4673
|
-
}
|
|
4674
|
-
bits |= (resb>0 ? 1 : 0) * power;
|
|
4675
|
-
power <<= 1;
|
|
4676
|
-
}
|
|
4677
|
-
|
|
4678
|
-
switch (next = bits) {
|
|
4679
|
-
case 0:
|
|
4680
|
-
bits = 0;
|
|
4681
|
-
maxpower = Math.pow(2,8);
|
|
4682
|
-
power=1;
|
|
4683
|
-
while (power!=maxpower) {
|
|
4684
|
-
resb = data.val & data.position;
|
|
4685
|
-
data.position >>= 1;
|
|
4686
|
-
if (data.position == 0) {
|
|
4687
|
-
data.position = resetValue;
|
|
4688
|
-
data.val = getNextValue(data.index++);
|
|
4689
|
-
}
|
|
4690
|
-
bits |= (resb>0 ? 1 : 0) * power;
|
|
4691
|
-
power <<= 1;
|
|
4692
|
-
}
|
|
4693
|
-
c = f(bits);
|
|
4694
|
-
break;
|
|
4695
|
-
case 1:
|
|
4696
|
-
bits = 0;
|
|
4697
|
-
maxpower = Math.pow(2,16);
|
|
4698
|
-
power=1;
|
|
4699
|
-
while (power!=maxpower) {
|
|
4700
|
-
resb = data.val & data.position;
|
|
4701
|
-
data.position >>= 1;
|
|
4702
|
-
if (data.position == 0) {
|
|
4703
|
-
data.position = resetValue;
|
|
4704
|
-
data.val = getNextValue(data.index++);
|
|
4705
|
-
}
|
|
4706
|
-
bits |= (resb>0 ? 1 : 0) * power;
|
|
4707
|
-
power <<= 1;
|
|
4708
|
-
}
|
|
4709
|
-
c = f(bits);
|
|
4710
|
-
break;
|
|
4711
|
-
case 2:
|
|
4712
|
-
return "";
|
|
4713
|
-
}
|
|
4714
|
-
dictionary[3] = c;
|
|
4715
|
-
w = c;
|
|
4716
|
-
result.push(c);
|
|
4717
|
-
while (true) {
|
|
4718
|
-
if (data.index > length) {
|
|
4719
|
-
return "";
|
|
4720
|
-
}
|
|
4721
|
-
|
|
4722
|
-
bits = 0;
|
|
4723
|
-
maxpower = Math.pow(2,numBits);
|
|
4724
|
-
power=1;
|
|
4725
|
-
while (power!=maxpower) {
|
|
4726
|
-
resb = data.val & data.position;
|
|
4727
|
-
data.position >>= 1;
|
|
4728
|
-
if (data.position == 0) {
|
|
4729
|
-
data.position = resetValue;
|
|
4730
|
-
data.val = getNextValue(data.index++);
|
|
4731
|
-
}
|
|
4732
|
-
bits |= (resb>0 ? 1 : 0) * power;
|
|
4733
|
-
power <<= 1;
|
|
4734
|
-
}
|
|
4735
|
-
|
|
4736
|
-
switch (c = bits) {
|
|
4737
|
-
case 0:
|
|
4738
|
-
bits = 0;
|
|
4739
|
-
maxpower = Math.pow(2,8);
|
|
4740
|
-
power=1;
|
|
4741
|
-
while (power!=maxpower) {
|
|
4742
|
-
resb = data.val & data.position;
|
|
4743
|
-
data.position >>= 1;
|
|
4744
|
-
if (data.position == 0) {
|
|
4745
|
-
data.position = resetValue;
|
|
4746
|
-
data.val = getNextValue(data.index++);
|
|
4747
|
-
}
|
|
4748
|
-
bits |= (resb>0 ? 1 : 0) * power;
|
|
4749
|
-
power <<= 1;
|
|
4750
|
-
}
|
|
4751
|
-
|
|
4752
|
-
dictionary[dictSize++] = f(bits);
|
|
4753
|
-
c = dictSize-1;
|
|
4754
|
-
enlargeIn--;
|
|
4755
|
-
break;
|
|
4756
|
-
case 1:
|
|
4757
|
-
bits = 0;
|
|
4758
|
-
maxpower = Math.pow(2,16);
|
|
4759
|
-
power=1;
|
|
4760
|
-
while (power!=maxpower) {
|
|
4761
|
-
resb = data.val & data.position;
|
|
4762
|
-
data.position >>= 1;
|
|
4763
|
-
if (data.position == 0) {
|
|
4764
|
-
data.position = resetValue;
|
|
4765
|
-
data.val = getNextValue(data.index++);
|
|
4766
|
-
}
|
|
4767
|
-
bits |= (resb>0 ? 1 : 0) * power;
|
|
4768
|
-
power <<= 1;
|
|
4769
|
-
}
|
|
4770
|
-
dictionary[dictSize++] = f(bits);
|
|
4771
|
-
c = dictSize-1;
|
|
4772
|
-
enlargeIn--;
|
|
4773
|
-
break;
|
|
4774
|
-
case 2:
|
|
4775
|
-
return result.join('');
|
|
4776
|
-
}
|
|
4777
|
-
|
|
4778
|
-
if (enlargeIn == 0) {
|
|
4779
|
-
enlargeIn = Math.pow(2, numBits);
|
|
4780
|
-
numBits++;
|
|
4781
|
-
}
|
|
4616
|
+
0x198: 0x2100000,
|
|
4617
|
+
0x1a8: 0x0,
|
|
4618
|
+
0x1b8: 0x2100401,
|
|
4619
|
+
0x1c8: 0x100401,
|
|
4620
|
+
0x1d8: 0x400,
|
|
4621
|
+
0x1e8: 0x2000400,
|
|
4622
|
+
0x1f8: 0x100001
|
|
4623
|
+
},
|
|
4624
|
+
{
|
|
4625
|
+
0x0: 0x8000820,
|
|
4626
|
+
0x1: 0x20000,
|
|
4627
|
+
0x2: 0x8000000,
|
|
4628
|
+
0x3: 0x20,
|
|
4629
|
+
0x4: 0x20020,
|
|
4630
|
+
0x5: 0x8020820,
|
|
4631
|
+
0x6: 0x8020800,
|
|
4632
|
+
0x7: 0x800,
|
|
4633
|
+
0x8: 0x8020000,
|
|
4634
|
+
0x9: 0x8000800,
|
|
4635
|
+
0xa: 0x20800,
|
|
4636
|
+
0xb: 0x8020020,
|
|
4637
|
+
0xc: 0x820,
|
|
4638
|
+
0xd: 0x0,
|
|
4639
|
+
0xe: 0x8000020,
|
|
4640
|
+
0xf: 0x20820,
|
|
4641
|
+
0x80000000: 0x800,
|
|
4642
|
+
0x80000001: 0x8020820,
|
|
4643
|
+
0x80000002: 0x8000820,
|
|
4644
|
+
0x80000003: 0x8000000,
|
|
4645
|
+
0x80000004: 0x8020000,
|
|
4646
|
+
0x80000005: 0x20800,
|
|
4647
|
+
0x80000006: 0x20820,
|
|
4648
|
+
0x80000007: 0x20,
|
|
4649
|
+
0x80000008: 0x8000020,
|
|
4650
|
+
0x80000009: 0x820,
|
|
4651
|
+
0x8000000a: 0x20020,
|
|
4652
|
+
0x8000000b: 0x8020800,
|
|
4653
|
+
0x8000000c: 0x0,
|
|
4654
|
+
0x8000000d: 0x8020020,
|
|
4655
|
+
0x8000000e: 0x8000800,
|
|
4656
|
+
0x8000000f: 0x20000,
|
|
4657
|
+
0x10: 0x20820,
|
|
4658
|
+
0x11: 0x8020800,
|
|
4659
|
+
0x12: 0x20,
|
|
4660
|
+
0x13: 0x800,
|
|
4661
|
+
0x14: 0x8000800,
|
|
4662
|
+
0x15: 0x8000020,
|
|
4663
|
+
0x16: 0x8020020,
|
|
4664
|
+
0x17: 0x20000,
|
|
4665
|
+
0x18: 0x0,
|
|
4666
|
+
0x19: 0x20020,
|
|
4667
|
+
0x1a: 0x8020000,
|
|
4668
|
+
0x1b: 0x8000820,
|
|
4669
|
+
0x1c: 0x8020820,
|
|
4670
|
+
0x1d: 0x20800,
|
|
4671
|
+
0x1e: 0x820,
|
|
4672
|
+
0x1f: 0x8000000,
|
|
4673
|
+
0x80000010: 0x20000,
|
|
4674
|
+
0x80000011: 0x800,
|
|
4675
|
+
0x80000012: 0x8020020,
|
|
4676
|
+
0x80000013: 0x20820,
|
|
4677
|
+
0x80000014: 0x20,
|
|
4678
|
+
0x80000015: 0x8020000,
|
|
4679
|
+
0x80000016: 0x8000000,
|
|
4680
|
+
0x80000017: 0x8000820,
|
|
4681
|
+
0x80000018: 0x8020820,
|
|
4682
|
+
0x80000019: 0x8000020,
|
|
4683
|
+
0x8000001a: 0x8000800,
|
|
4684
|
+
0x8000001b: 0x0,
|
|
4685
|
+
0x8000001c: 0x20800,
|
|
4686
|
+
0x8000001d: 0x820,
|
|
4687
|
+
0x8000001e: 0x20020,
|
|
4688
|
+
0x8000001f: 0x8020800
|
|
4689
|
+
}
|
|
4690
|
+
];
|
|
4782
4691
|
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
} else {
|
|
4789
|
-
return null;
|
|
4790
|
-
}
|
|
4791
|
-
}
|
|
4792
|
-
result.push(entry);
|
|
4692
|
+
// Masks that select the SBOX input
|
|
4693
|
+
var SBOX_MASK = [
|
|
4694
|
+
0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
|
|
4695
|
+
0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
|
|
4696
|
+
];
|
|
4793
4697
|
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4698
|
+
/**
|
|
4699
|
+
* DES block cipher algorithm.
|
|
4700
|
+
*/
|
|
4701
|
+
var DES = C_algo.DES = BlockCipher.extend({
|
|
4702
|
+
_doReset: function () {
|
|
4703
|
+
// Shortcuts
|
|
4704
|
+
var key = this._key;
|
|
4705
|
+
var keyWords = key.words;
|
|
4797
4706
|
|
|
4798
|
-
|
|
4707
|
+
// Select 56 bits according to PC1
|
|
4708
|
+
var keyBits = [];
|
|
4709
|
+
for (var i = 0; i < 56; i++) {
|
|
4710
|
+
var keyBitPos = PC1[i] - 1;
|
|
4711
|
+
keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
|
|
4712
|
+
}
|
|
4799
4713
|
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4714
|
+
// Assemble 16 subkeys
|
|
4715
|
+
var subKeys = this._subKeys = [];
|
|
4716
|
+
for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
|
|
4717
|
+
// Create subkey
|
|
4718
|
+
var subKey = subKeys[nSubKey] = [];
|
|
4804
4719
|
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
};
|
|
4808
|
-
return LZString;
|
|
4809
|
-
})();
|
|
4720
|
+
// Shortcut
|
|
4721
|
+
var bitShift = BIT_SHIFTS[nSubKey];
|
|
4810
4722
|
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
{}
|
|
4723
|
+
// Select 48 bits according to PC2
|
|
4724
|
+
for (var i = 0; i < 24; i++) {
|
|
4725
|
+
// Select from the left 28 key bits
|
|
4726
|
+
subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
|
|
4816
4727
|
|
|
4728
|
+
// Select from the right 28 key bits
|
|
4729
|
+
subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
|
|
4730
|
+
}
|
|
4817
4731
|
|
|
4818
|
-
|
|
4732
|
+
// Since each subkey is applied to an expanded 32-bit input,
|
|
4733
|
+
// the subkey can be broken into 8 values scaled to 32-bits,
|
|
4734
|
+
// which allows the key to be used without expansion
|
|
4735
|
+
subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
|
|
4736
|
+
for (var i = 1; i < 7; i++) {
|
|
4737
|
+
subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
|
|
4738
|
+
}
|
|
4739
|
+
subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
|
|
4740
|
+
}
|
|
4819
4741
|
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4742
|
+
// Compute inverse subkeys
|
|
4743
|
+
var invSubKeys = this._invSubKeys = [];
|
|
4744
|
+
for (var i = 0; i < 16; i++) {
|
|
4745
|
+
invSubKeys[i] = subKeys[15 - i];
|
|
4746
|
+
}
|
|
4747
|
+
},
|
|
4825
4748
|
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
4830
|
-
/* harmony export */ });
|
|
4831
|
-
const Base64 = {
|
|
4832
|
-
_keyStr: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
|
|
4833
|
-
encode: function (e) {
|
|
4834
|
-
let t = '';
|
|
4835
|
-
let n, r, i, s, o, u, a;
|
|
4836
|
-
let f = 0;
|
|
4837
|
-
e = Base64._utf8Encode(e);
|
|
4838
|
-
while (f < e.length) {
|
|
4839
|
-
n = e.charCodeAt(f++);
|
|
4840
|
-
r = e.charCodeAt(f++);
|
|
4841
|
-
i = e.charCodeAt(f++);
|
|
4842
|
-
s = n >> 2;
|
|
4843
|
-
o = (n & 3) << 4 | r >> 4;
|
|
4844
|
-
u = (r & 15) << 2 | i >> 6;
|
|
4845
|
-
a = i & 63;
|
|
4846
|
-
if (isNaN(r)) {
|
|
4847
|
-
u = a = 64;
|
|
4848
|
-
} else if (isNaN(i)) {
|
|
4849
|
-
a = 64;
|
|
4850
|
-
}
|
|
4851
|
-
t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) + this._keyStr.charAt(u) + this._keyStr.charAt(a);
|
|
4852
|
-
}
|
|
4853
|
-
return t;
|
|
4854
|
-
},
|
|
4855
|
-
decode: function (e) {
|
|
4856
|
-
let t = '';
|
|
4857
|
-
let n, r, i;
|
|
4858
|
-
let s, o, u, a;
|
|
4859
|
-
let f = 0;
|
|
4860
|
-
e = e.replace(/[^A-Za-z0-9+/=]/g, '');
|
|
4861
|
-
while (f < e.length) {
|
|
4862
|
-
s = this._keyStr.indexOf(e.charAt(f++));
|
|
4863
|
-
o = this._keyStr.indexOf(e.charAt(f++));
|
|
4864
|
-
u = this._keyStr.indexOf(e.charAt(f++));
|
|
4865
|
-
a = this._keyStr.indexOf(e.charAt(f++));
|
|
4866
|
-
n = s << 2 | o >> 4;
|
|
4867
|
-
r = (o & 15) << 4 | u >> 2;
|
|
4868
|
-
i = (u & 3) << 6 | a;
|
|
4869
|
-
t = t + String.fromCharCode(n);
|
|
4870
|
-
if (u !== 64) {
|
|
4871
|
-
t = t + String.fromCharCode(r);
|
|
4872
|
-
}
|
|
4873
|
-
if (a !== 64) {
|
|
4874
|
-
t = t + String.fromCharCode(i);
|
|
4875
|
-
}
|
|
4876
|
-
}
|
|
4877
|
-
t = Base64._utf8Decode(t);
|
|
4878
|
-
return t;
|
|
4879
|
-
},
|
|
4880
|
-
_utf8Encode: function (e) {
|
|
4881
|
-
e = e.replace(/\r\n/g, '\n');
|
|
4882
|
-
let t = '';
|
|
4883
|
-
for (let n = 0; n < e.length; n++) {
|
|
4884
|
-
let r = e.charCodeAt(n);
|
|
4885
|
-
if (r < 128) {
|
|
4886
|
-
t += String.fromCharCode(r);
|
|
4887
|
-
} else if (r > 127 && r < 2048) {
|
|
4888
|
-
t += String.fromCharCode(r >> 6 | 192);
|
|
4889
|
-
t += String.fromCharCode(r & 63 | 128);
|
|
4890
|
-
} else {
|
|
4891
|
-
t += String.fromCharCode(r >> 12 | 224);
|
|
4892
|
-
t += String.fromCharCode(r >> 6 & 63 | 128);
|
|
4893
|
-
t += String.fromCharCode(r & 63 | 128);
|
|
4894
|
-
}
|
|
4895
|
-
}
|
|
4896
|
-
return t;
|
|
4897
|
-
},
|
|
4898
|
-
_utf8Decode: function (e) {
|
|
4899
|
-
let t = '';
|
|
4900
|
-
let n = 0;
|
|
4901
|
-
let r, c2, c3;
|
|
4902
|
-
r = c2 = 0;
|
|
4903
|
-
while (n < e.length) {
|
|
4904
|
-
r = e.charCodeAt(n);
|
|
4905
|
-
if (r < 128) {
|
|
4906
|
-
t += String.fromCharCode(r);
|
|
4907
|
-
n++;
|
|
4908
|
-
} else if (r > 191 && r < 224) {
|
|
4909
|
-
c2 = e.charCodeAt(n + 1);
|
|
4910
|
-
t += String.fromCharCode((r & 31) << 6 | c2 & 63);
|
|
4911
|
-
n += 2;
|
|
4912
|
-
} else {
|
|
4913
|
-
c2 = e.charCodeAt(n + 1);
|
|
4914
|
-
c3 = e.charCodeAt(n + 2);
|
|
4915
|
-
t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63);
|
|
4916
|
-
n += 3;
|
|
4917
|
-
}
|
|
4918
|
-
}
|
|
4919
|
-
return t;
|
|
4920
|
-
}
|
|
4921
|
-
};
|
|
4922
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Base64);
|
|
4749
|
+
encryptBlock: function (M, offset) {
|
|
4750
|
+
this._doCryptBlock(M, offset, this._subKeys);
|
|
4751
|
+
},
|
|
4923
4752
|
|
|
4924
|
-
|
|
4753
|
+
decryptBlock: function (M, offset) {
|
|
4754
|
+
this._doCryptBlock(M, offset, this._invSubKeys);
|
|
4755
|
+
},
|
|
4925
4756
|
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
4757
|
+
_doCryptBlock: function (M, offset, subKeys) {
|
|
4758
|
+
// Get input
|
|
4759
|
+
this._lBlock = M[offset];
|
|
4760
|
+
this._rBlock = M[offset + 1];
|
|
4931
4761
|
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
/* harmony import */ var _enc_utf8__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./enc-utf8 */ "./src/enc-utf8.js");
|
|
4939
|
-
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils */ "./src/utils.js");
|
|
4940
|
-
/* harmony import */ var crypto_js_aes__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! crypto-js/aes */ "./node_modules/crypto-js/aes.js");
|
|
4941
|
-
/* harmony import */ var crypto_js_aes__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(crypto_js_aes__WEBPACK_IMPORTED_MODULE_3__);
|
|
4942
|
-
/* harmony import */ var crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! crypto-js/rabbit */ "./node_modules/crypto-js/rabbit.js");
|
|
4943
|
-
/* harmony import */ var crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4__);
|
|
4944
|
-
/* harmony import */ var crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! crypto-js/rc4 */ "./node_modules/crypto-js/rc4.js");
|
|
4945
|
-
/* harmony import */ var crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5__);
|
|
4946
|
-
/* harmony import */ var crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! crypto-js/tripledes */ "./node_modules/crypto-js/tripledes.js");
|
|
4947
|
-
/* harmony import */ var crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6__);
|
|
4948
|
-
/* harmony import */ var lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! lz-string/libs/lz-string */ "./node_modules/lz-string/libs/lz-string.js");
|
|
4949
|
-
/* harmony import */ var lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7__);
|
|
4950
|
-
/* harmony import */ var _Base64__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Base64 */ "./src/Base64.js");
|
|
4762
|
+
// Initial permutation
|
|
4763
|
+
exchangeLR.call(this, 4, 0x0f0f0f0f);
|
|
4764
|
+
exchangeLR.call(this, 16, 0x0000ffff);
|
|
4765
|
+
exchangeRL.call(this, 2, 0x33333333);
|
|
4766
|
+
exchangeRL.call(this, 8, 0x00ff00ff);
|
|
4767
|
+
exchangeLR.call(this, 1, 0x55555555);
|
|
4951
4768
|
|
|
4769
|
+
// Rounds
|
|
4770
|
+
for (var round = 0; round < 16; round++) {
|
|
4771
|
+
// Shortcuts
|
|
4772
|
+
var subKey = subKeys[round];
|
|
4773
|
+
var lBlock = this._lBlock;
|
|
4774
|
+
var rBlock = this._rBlock;
|
|
4952
4775
|
|
|
4776
|
+
// Feistel function
|
|
4777
|
+
var f = 0;
|
|
4778
|
+
for (var i = 0; i < 8; i++) {
|
|
4779
|
+
f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
|
|
4780
|
+
}
|
|
4781
|
+
this._lBlock = rBlock;
|
|
4782
|
+
this._rBlock = lBlock ^ f;
|
|
4783
|
+
}
|
|
4953
4784
|
|
|
4785
|
+
// Undo swap from last round
|
|
4786
|
+
var t = this._lBlock;
|
|
4787
|
+
this._lBlock = this._rBlock;
|
|
4788
|
+
this._rBlock = t;
|
|
4954
4789
|
|
|
4790
|
+
// Final permutation
|
|
4791
|
+
exchangeLR.call(this, 1, 0x55555555);
|
|
4792
|
+
exchangeRL.call(this, 8, 0x00ff00ff);
|
|
4793
|
+
exchangeRL.call(this, 2, 0x33333333);
|
|
4794
|
+
exchangeLR.call(this, 16, 0x0000ffff);
|
|
4795
|
+
exchangeLR.call(this, 4, 0x0f0f0f0f);
|
|
4955
4796
|
|
|
4797
|
+
// Set output
|
|
4798
|
+
M[offset] = this._lBlock;
|
|
4799
|
+
M[offset + 1] = this._rBlock;
|
|
4800
|
+
},
|
|
4956
4801
|
|
|
4802
|
+
keySize: 64/32,
|
|
4957
4803
|
|
|
4804
|
+
ivSize: 64/32,
|
|
4958
4805
|
|
|
4806
|
+
blockSize: 64/32
|
|
4807
|
+
});
|
|
4959
4808
|
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
}
|
|
4966
|
-
class SecureLS {
|
|
4967
|
-
constructor({
|
|
4968
|
-
encryptionSecret = '',
|
|
4969
|
-
encryptionNamespace = '',
|
|
4970
|
-
isCompression = true,
|
|
4971
|
-
encodingType = _constants__WEBPACK_IMPORTED_MODULE_0__["default"].EncrytionTypes.BASE64,
|
|
4972
|
-
storage = localStorage,
|
|
4973
|
-
metaKey = _constants__WEBPACK_IMPORTED_MODULE_0__["default"].metaKey
|
|
4974
|
-
} = {}) {
|
|
4975
|
-
// Assign libraries and utilities
|
|
4976
|
-
Object.assign(this, {
|
|
4977
|
-
_name: 'secure-ls',
|
|
4978
|
-
Base64: _Base64__WEBPACK_IMPORTED_MODULE_8__["default"],
|
|
4979
|
-
LZString: {
|
|
4980
|
-
compressToUTF16: lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7__.compressToUTF16,
|
|
4981
|
-
decompressFromUTF16: lz_string_libs_lz_string__WEBPACK_IMPORTED_MODULE_7__.decompressFromUTF16
|
|
4982
|
-
},
|
|
4983
|
-
AES: (crypto_js_aes__WEBPACK_IMPORTED_MODULE_3___default()),
|
|
4984
|
-
DES: (crypto_js_tripledes__WEBPACK_IMPORTED_MODULE_6___default()),
|
|
4985
|
-
RABBIT: (crypto_js_rabbit__WEBPACK_IMPORTED_MODULE_4___default()),
|
|
4986
|
-
RC4: (crypto_js_rc4__WEBPACK_IMPORTED_MODULE_5___default()),
|
|
4987
|
-
enc: _enc_utf8__WEBPACK_IMPORTED_MODULE_1__["default"]
|
|
4988
|
-
});
|
|
4809
|
+
// Swap bits across the left and right words
|
|
4810
|
+
function exchangeLR(offset, mask) {
|
|
4811
|
+
var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
|
|
4812
|
+
this._rBlock ^= t;
|
|
4813
|
+
this._lBlock ^= t << offset;
|
|
4814
|
+
}
|
|
4989
4815
|
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
encodingType: encodingType.toLowerCase(),
|
|
4996
|
-
storage,
|
|
4997
|
-
metaKey
|
|
4998
|
-
};
|
|
4999
|
-
this.encryptionSecret = encryptionSecret;
|
|
5000
|
-
this.storage = storage;
|
|
5001
|
-
this.metaKey = metaKey;
|
|
4816
|
+
function exchangeRL(offset, mask) {
|
|
4817
|
+
var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
|
|
4818
|
+
this._lBlock ^= t;
|
|
4819
|
+
this._rBlock ^= t << offset;
|
|
4820
|
+
}
|
|
5002
4821
|
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
this._isRC4 = this._isRC4EncryptionType();
|
|
5013
|
-
this._isCompression = this._isDataCompressionEnabled();
|
|
4822
|
+
/**
|
|
4823
|
+
* Shortcut functions to the cipher's object interface.
|
|
4824
|
+
*
|
|
4825
|
+
* @example
|
|
4826
|
+
*
|
|
4827
|
+
* var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
|
|
4828
|
+
* var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg);
|
|
4829
|
+
*/
|
|
4830
|
+
C.DES = BlockCipher._createHelper(DES);
|
|
5014
4831
|
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
4832
|
+
/**
|
|
4833
|
+
* Triple-DES block cipher algorithm.
|
|
4834
|
+
*/
|
|
4835
|
+
var TripleDES = C_algo.TripleDES = BlockCipher.extend({
|
|
4836
|
+
_doReset: function () {
|
|
4837
|
+
// Shortcuts
|
|
4838
|
+
var key = this._key;
|
|
4839
|
+
var keyWords = key.words;
|
|
4840
|
+
// Make sure the key length is valid (64, 128 or >= 192 bit)
|
|
4841
|
+
if (keyWords.length !== 2 && keyWords.length !== 4 && keyWords.length < 6) {
|
|
4842
|
+
throw new Error('Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.');
|
|
4843
|
+
}
|
|
4844
|
+
|
|
4845
|
+
// Extend the key according to the keying options defined in 3DES standard
|
|
4846
|
+
var key1 = keyWords.slice(0, 2);
|
|
4847
|
+
var key2 = keyWords.length < 4 ? keyWords.slice(0, 2) : keyWords.slice(2, 4);
|
|
4848
|
+
var key3 = keyWords.length < 6 ? keyWords.slice(0, 2) : keyWords.slice(4, 6);
|
|
4849
|
+
|
|
4850
|
+
// Create DES instances
|
|
4851
|
+
this._des1 = DES.createEncryptor(WordArray.create(key1));
|
|
4852
|
+
this._des2 = DES.createEncryptor(WordArray.create(key2));
|
|
4853
|
+
this._des3 = DES.createEncryptor(WordArray.create(key3));
|
|
4854
|
+
},
|
|
4855
|
+
|
|
4856
|
+
encryptBlock: function (M, offset) {
|
|
4857
|
+
this._des1.encryptBlock(M, offset);
|
|
4858
|
+
this._des2.decryptBlock(M, offset);
|
|
4859
|
+
this._des3.encryptBlock(M, offset);
|
|
4860
|
+
},
|
|
4861
|
+
|
|
4862
|
+
decryptBlock: function (M, offset) {
|
|
4863
|
+
this._des3.decryptBlock(M, offset);
|
|
4864
|
+
this._des2.encryptBlock(M, offset);
|
|
4865
|
+
this._des1.decryptBlock(M, offset);
|
|
4866
|
+
},
|
|
4867
|
+
|
|
4868
|
+
keySize: 192/32,
|
|
4869
|
+
|
|
4870
|
+
ivSize: 64/32,
|
|
4871
|
+
|
|
4872
|
+
blockSize: 64/32
|
|
4873
|
+
});
|
|
4874
|
+
|
|
4875
|
+
/**
|
|
4876
|
+
* Shortcut functions to the cipher's object interface.
|
|
4877
|
+
*
|
|
4878
|
+
* @example
|
|
4879
|
+
*
|
|
4880
|
+
* var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
|
|
4881
|
+
* var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
|
|
4882
|
+
*/
|
|
4883
|
+
C.TripleDES = BlockCipher._createHelper(TripleDES);
|
|
4884
|
+
}());
|
|
4885
|
+
|
|
4886
|
+
|
|
4887
|
+
return CryptoJS.TripleDES;
|
|
4888
|
+
|
|
4889
|
+
}));
|
|
4890
|
+
|
|
4891
|
+
/***/ },
|
|
5068
4892
|
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
}
|
|
5075
|
-
getMetaKey() {
|
|
5076
|
-
return this.metaKey + (this.config.encryptionNamespace ? '__' + this.config.encryptionNamespace : '');
|
|
5077
|
-
}
|
|
5078
|
-
resetAllKeys() {
|
|
5079
|
-
this.allKeys = [];
|
|
5080
|
-
return [];
|
|
5081
|
-
}
|
|
5082
|
-
processData(data, isAllKeysData) {
|
|
5083
|
-
if (data === null || data === undefined || data === '') {
|
|
5084
|
-
return '';
|
|
5085
|
-
}
|
|
5086
|
-
let jsonData;
|
|
5087
|
-
try {
|
|
5088
|
-
jsonData = JSON.stringify(data);
|
|
5089
|
-
} catch (err) {
|
|
5090
|
-
throw new Error('Could not stringify data', err);
|
|
5091
|
-
}
|
|
4893
|
+
/***/ "./node_modules/lz-string/libs/lz-string.js"
|
|
4894
|
+
/*!**************************************************!*\
|
|
4895
|
+
!*** ./node_modules/lz-string/libs/lz-string.js ***!
|
|
4896
|
+
\**************************************************/
|
|
4897
|
+
(module, exports, __webpack_require__) {
|
|
5092
4898
|
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
encodedData = encodedData && encodedData.toString();
|
|
5104
|
-
}
|
|
4899
|
+
var __WEBPACK_AMD_DEFINE_RESULT__;// Copyright (c) 2013 Pieroxy <pieroxy@pieroxy.net>
|
|
4900
|
+
// This work is free. You can redistribute it and/or modify it
|
|
4901
|
+
// under the terms of the WTFPL, Version 2
|
|
4902
|
+
// For more information see LICENSE.txt or http://www.wtfpl.net/
|
|
4903
|
+
//
|
|
4904
|
+
// For more information, the home page:
|
|
4905
|
+
// http://pieroxy.net/blog/pages/lz-string/testing.html
|
|
4906
|
+
//
|
|
4907
|
+
// LZ-based compression algorithm, version 1.4.5
|
|
4908
|
+
var LZString = (function() {
|
|
5105
4909
|
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
4910
|
+
// private property
|
|
4911
|
+
var f = String.fromCharCode;
|
|
4912
|
+
var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
4913
|
+
var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
|
|
4914
|
+
var baseReverseDic = {};
|
|
4915
|
+
|
|
4916
|
+
function getBaseValue(alphabet, character) {
|
|
4917
|
+
if (!baseReverseDic[alphabet]) {
|
|
4918
|
+
baseReverseDic[alphabet] = {};
|
|
4919
|
+
for (var i=0 ; i<alphabet.length ; i++) {
|
|
4920
|
+
baseReverseDic[alphabet][alphabet.charAt(i)] = i;
|
|
5110
4921
|
}
|
|
5111
|
-
return compressedData;
|
|
5112
4922
|
}
|
|
4923
|
+
return baseReverseDic[alphabet][character];
|
|
4924
|
+
}
|
|
5113
4925
|
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
return
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
return jsonData;
|
|
5125
|
-
}
|
|
5126
|
-
let data = this.getDataFromLocalStorage(key);
|
|
5127
|
-
if (!data) {
|
|
5128
|
-
return jsonData;
|
|
4926
|
+
var LZString = {
|
|
4927
|
+
compressToBase64 : function (input) {
|
|
4928
|
+
if (input == null) return "";
|
|
4929
|
+
var res = LZString._compress(input, 6, function(a){return keyStrBase64.charAt(a);});
|
|
4930
|
+
switch (res.length % 4) { // To produce valid Base64
|
|
4931
|
+
default: // When could this happen ?
|
|
4932
|
+
case 0 : return res;
|
|
4933
|
+
case 1 : return res+"===";
|
|
4934
|
+
case 2 : return res+"==";
|
|
4935
|
+
case 3 : return res+"=";
|
|
5129
4936
|
}
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
4937
|
+
},
|
|
4938
|
+
|
|
4939
|
+
decompressFromBase64 : function (input) {
|
|
4940
|
+
if (input == null) return "";
|
|
4941
|
+
if (input == "") return null;
|
|
4942
|
+
return LZString._decompress(input.length, 32, function(index) { return getBaseValue(keyStrBase64, input.charAt(index)); });
|
|
4943
|
+
},
|
|
4944
|
+
|
|
4945
|
+
compressToUTF16 : function (input) {
|
|
4946
|
+
if (input == null) return "";
|
|
4947
|
+
return LZString._compress(input, 15, function(a){return f(a+32);}) + " ";
|
|
4948
|
+
},
|
|
4949
|
+
|
|
4950
|
+
decompressFromUTF16: function (compressed) {
|
|
4951
|
+
if (compressed == null) return "";
|
|
4952
|
+
if (compressed == "") return null;
|
|
4953
|
+
return LZString._decompress(compressed.length, 16384, function(index) { return compressed.charCodeAt(index) - 32; });
|
|
4954
|
+
},
|
|
4955
|
+
|
|
4956
|
+
//compress into uint8array (UCS-2 big endian format)
|
|
4957
|
+
compressToUint8Array: function (uncompressed) {
|
|
4958
|
+
var compressed = LZString.compress(uncompressed);
|
|
4959
|
+
var buf=new Uint8Array(compressed.length*2); // 2 bytes per character
|
|
4960
|
+
|
|
4961
|
+
for (var i=0, TotalLen=compressed.length; i<TotalLen; i++) {
|
|
4962
|
+
var current_value = compressed.charCodeAt(i);
|
|
4963
|
+
buf[i*2] = current_value >>> 8;
|
|
4964
|
+
buf[i*2+1] = current_value % 256;
|
|
5134
4965
|
}
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
4966
|
+
return buf;
|
|
4967
|
+
},
|
|
4968
|
+
|
|
4969
|
+
//decompress from uint8array (UCS-2 big endian format)
|
|
4970
|
+
decompressFromUint8Array:function (compressed) {
|
|
4971
|
+
if (compressed===null || compressed===undefined){
|
|
4972
|
+
return LZString.decompress(compressed);
|
|
5139
4973
|
} else {
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
const bytes = encryptor.decrypt(deCompressedData.toString(), this.encryptionSecret);
|
|
5144
|
-
if (bytes) {
|
|
5145
|
-
decodedData = bytes.toString(_enc_utf8__WEBPACK_IMPORTED_MODULE_1__["default"]._Utf8);
|
|
4974
|
+
var buf=new Array(compressed.length/2); // 2 bytes per character
|
|
4975
|
+
for (var i=0, TotalLen=buf.length; i<TotalLen; i++) {
|
|
4976
|
+
buf[i]=compressed[i*2]*256+compressed[i*2+1];
|
|
5146
4977
|
}
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
return jsonData;
|
|
5155
|
-
}
|
|
5156
|
-
set(key, data) {
|
|
5157
|
-
let dataToStore = '';
|
|
5158
|
-
if (!_utils__WEBPACK_IMPORTED_MODULE_2__["default"].is(key)) {
|
|
5159
|
-
_utils__WEBPACK_IMPORTED_MODULE_2__["default"].warn(_constants__WEBPACK_IMPORTED_MODULE_0__["default"].WarningEnum.KEY_NOT_PROVIDED);
|
|
5160
|
-
return;
|
|
4978
|
+
|
|
4979
|
+
var result = [];
|
|
4980
|
+
buf.forEach(function (c) {
|
|
4981
|
+
result.push(f(c));
|
|
4982
|
+
});
|
|
4983
|
+
return LZString.decompress(result.join(''));
|
|
4984
|
+
|
|
5161
4985
|
}
|
|
5162
|
-
this.getEncryptionSecret(key);
|
|
5163
4986
|
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
4987
|
+
},
|
|
4988
|
+
|
|
4989
|
+
|
|
4990
|
+
//compress into a string that is already URI encoded
|
|
4991
|
+
compressToEncodedURIComponent: function (input) {
|
|
4992
|
+
if (input == null) return "";
|
|
4993
|
+
return LZString._compress(input, 6, function(a){return keyStrUriSafe.charAt(a);});
|
|
4994
|
+
},
|
|
4995
|
+
|
|
4996
|
+
//decompress from an output of compressToEncodedURIComponent
|
|
4997
|
+
decompressFromEncodedURIComponent:function (input) {
|
|
4998
|
+
if (input == null) return "";
|
|
4999
|
+
if (input == "") return null;
|
|
5000
|
+
input = input.replace(/ /g, "+");
|
|
5001
|
+
return LZString._decompress(input.length, 32, function(index) { return getBaseValue(keyStrUriSafe, input.charAt(index)); });
|
|
5002
|
+
},
|
|
5003
|
+
|
|
5004
|
+
compress: function (uncompressed) {
|
|
5005
|
+
return LZString._compress(uncompressed, 16, function(a){return f(a);});
|
|
5006
|
+
},
|
|
5007
|
+
_compress: function (uncompressed, bitsPerChar, getCharFromInt) {
|
|
5008
|
+
if (uncompressed == null) return "";
|
|
5009
|
+
var i, value,
|
|
5010
|
+
context_dictionary= {},
|
|
5011
|
+
context_dictionaryToCreate= {},
|
|
5012
|
+
context_c="",
|
|
5013
|
+
context_wc="",
|
|
5014
|
+
context_w="",
|
|
5015
|
+
context_enlargeIn= 2, // Compensate for the first entry which should not count
|
|
5016
|
+
context_dictSize= 3,
|
|
5017
|
+
context_numBits= 2,
|
|
5018
|
+
context_data=[],
|
|
5019
|
+
context_data_val=0,
|
|
5020
|
+
context_data_position=0,
|
|
5021
|
+
ii;
|
|
5022
|
+
|
|
5023
|
+
for (ii = 0; ii < uncompressed.length; ii += 1) {
|
|
5024
|
+
context_c = uncompressed.charAt(ii);
|
|
5025
|
+
if (!Object.prototype.hasOwnProperty.call(context_dictionary,context_c)) {
|
|
5026
|
+
context_dictionary[context_c] = context_dictSize++;
|
|
5027
|
+
context_dictionaryToCreate[context_c] = true;
|
|
5028
|
+
}
|
|
5029
|
+
|
|
5030
|
+
context_wc = context_w + context_c;
|
|
5031
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionary,context_wc)) {
|
|
5032
|
+
context_w = context_wc;
|
|
5033
|
+
} else {
|
|
5034
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate,context_w)) {
|
|
5035
|
+
if (context_w.charCodeAt(0)<256) {
|
|
5036
|
+
for (i=0 ; i<context_numBits ; i++) {
|
|
5037
|
+
context_data_val = (context_data_val << 1);
|
|
5038
|
+
if (context_data_position == bitsPerChar-1) {
|
|
5039
|
+
context_data_position = 0;
|
|
5040
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
5041
|
+
context_data_val = 0;
|
|
5042
|
+
} else {
|
|
5043
|
+
context_data_position++;
|
|
5044
|
+
}
|
|
5045
|
+
}
|
|
5046
|
+
value = context_w.charCodeAt(0);
|
|
5047
|
+
for (i=0 ; i<8 ; i++) {
|
|
5048
|
+
context_data_val = (context_data_val << 1) | (value&1);
|
|
5049
|
+
if (context_data_position == bitsPerChar-1) {
|
|
5050
|
+
context_data_position = 0;
|
|
5051
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
5052
|
+
context_data_val = 0;
|
|
5053
|
+
} else {
|
|
5054
|
+
context_data_position++;
|
|
5055
|
+
}
|
|
5056
|
+
value = value >> 1;
|
|
5057
|
+
}
|
|
5058
|
+
} else {
|
|
5059
|
+
value = 1;
|
|
5060
|
+
for (i=0 ; i<context_numBits ; i++) {
|
|
5061
|
+
context_data_val = (context_data_val << 1) | value;
|
|
5062
|
+
if (context_data_position ==bitsPerChar-1) {
|
|
5063
|
+
context_data_position = 0;
|
|
5064
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
5065
|
+
context_data_val = 0;
|
|
5066
|
+
} else {
|
|
5067
|
+
context_data_position++;
|
|
5068
|
+
}
|
|
5069
|
+
value = 0;
|
|
5070
|
+
}
|
|
5071
|
+
value = context_w.charCodeAt(0);
|
|
5072
|
+
for (i=0 ; i<16 ; i++) {
|
|
5073
|
+
context_data_val = (context_data_val << 1) | (value&1);
|
|
5074
|
+
if (context_data_position == bitsPerChar-1) {
|
|
5075
|
+
context_data_position = 0;
|
|
5076
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
5077
|
+
context_data_val = 0;
|
|
5078
|
+
} else {
|
|
5079
|
+
context_data_position++;
|
|
5080
|
+
}
|
|
5081
|
+
value = value >> 1;
|
|
5082
|
+
}
|
|
5083
|
+
}
|
|
5084
|
+
context_enlargeIn--;
|
|
5085
|
+
if (context_enlargeIn == 0) {
|
|
5086
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
5087
|
+
context_numBits++;
|
|
5088
|
+
}
|
|
5089
|
+
delete context_dictionaryToCreate[context_w];
|
|
5090
|
+
} else {
|
|
5091
|
+
value = context_dictionary[context_w];
|
|
5092
|
+
for (i=0 ; i<context_numBits ; i++) {
|
|
5093
|
+
context_data_val = (context_data_val << 1) | (value&1);
|
|
5094
|
+
if (context_data_position == bitsPerChar-1) {
|
|
5095
|
+
context_data_position = 0;
|
|
5096
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
5097
|
+
context_data_val = 0;
|
|
5098
|
+
} else {
|
|
5099
|
+
context_data_position++;
|
|
5100
|
+
}
|
|
5101
|
+
value = value >> 1;
|
|
5102
|
+
}
|
|
5103
|
+
|
|
5104
|
+
|
|
5105
|
+
}
|
|
5106
|
+
context_enlargeIn--;
|
|
5107
|
+
if (context_enlargeIn == 0) {
|
|
5108
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
5109
|
+
context_numBits++;
|
|
5110
|
+
}
|
|
5111
|
+
// Add wc to the dictionary.
|
|
5112
|
+
context_dictionary[context_wc] = context_dictSize++;
|
|
5113
|
+
context_w = String(context_c);
|
|
5172
5114
|
}
|
|
5173
5115
|
}
|
|
5174
|
-
dataToStore = this.processData(data);
|
|
5175
|
-
// Store the data to localStorage
|
|
5176
|
-
this.setDataToLocalStorage(key, dataToStore);
|
|
5177
|
-
}
|
|
5178
|
-
remove(key) {
|
|
5179
|
-
if (!_utils__WEBPACK_IMPORTED_MODULE_2__["default"].is(key)) {
|
|
5180
|
-
_utils__WEBPACK_IMPORTED_MODULE_2__["default"].warn(_constants__WEBPACK_IMPORTED_MODULE_0__["default"].WarningEnum.KEY_NOT_PROVIDED);
|
|
5181
|
-
return;
|
|
5182
|
-
}
|
|
5183
|
-
if (key === this.metaKey && this.getAllKeys().length) {
|
|
5184
|
-
_utils__WEBPACK_IMPORTED_MODULE_2__["default"].warn(_constants__WEBPACK_IMPORTED_MODULE_0__["default"].WarningEnum.META_KEY_REMOVE);
|
|
5185
|
-
return;
|
|
5186
|
-
}
|
|
5187
|
-
if (_utils__WEBPACK_IMPORTED_MODULE_2__["default"].isKeyPresent(this.allKeys, key)) {
|
|
5188
|
-
_utils__WEBPACK_IMPORTED_MODULE_2__["default"].removeFromKeysList(this.allKeys, key);
|
|
5189
|
-
this.setMetaData();
|
|
5190
|
-
}
|
|
5191
|
-
this.storage.removeItem(key);
|
|
5192
|
-
}
|
|
5193
|
-
removeAll() {
|
|
5194
|
-
let keys = this.getAllKeys();
|
|
5195
|
-
for (let i = 0; i < keys.length; i++) {
|
|
5196
|
-
this.storage.removeItem(keys[i]);
|
|
5197
|
-
}
|
|
5198
|
-
this.storage.removeItem(this.metaKey);
|
|
5199
|
-
this.resetAllKeys();
|
|
5200
|
-
}
|
|
5201
|
-
clear() {
|
|
5202
|
-
this.storage.clear();
|
|
5203
|
-
this.resetAllKeys();
|
|
5204
|
-
}
|
|
5205
|
-
}
|
|
5206
|
-
|
|
5207
|
-
/***/ },
|
|
5208
5116
|
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
(
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5117
|
+
// Output the code for w.
|
|
5118
|
+
if (context_w !== "") {
|
|
5119
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate,context_w)) {
|
|
5120
|
+
if (context_w.charCodeAt(0)<256) {
|
|
5121
|
+
for (i=0 ; i<context_numBits ; i++) {
|
|
5122
|
+
context_data_val = (context_data_val << 1);
|
|
5123
|
+
if (context_data_position == bitsPerChar-1) {
|
|
5124
|
+
context_data_position = 0;
|
|
5125
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
5126
|
+
context_data_val = 0;
|
|
5127
|
+
} else {
|
|
5128
|
+
context_data_position++;
|
|
5129
|
+
}
|
|
5130
|
+
}
|
|
5131
|
+
value = context_w.charCodeAt(0);
|
|
5132
|
+
for (i=0 ; i<8 ; i++) {
|
|
5133
|
+
context_data_val = (context_data_val << 1) | (value&1);
|
|
5134
|
+
if (context_data_position == bitsPerChar-1) {
|
|
5135
|
+
context_data_position = 0;
|
|
5136
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
5137
|
+
context_data_val = 0;
|
|
5138
|
+
} else {
|
|
5139
|
+
context_data_position++;
|
|
5140
|
+
}
|
|
5141
|
+
value = value >> 1;
|
|
5142
|
+
}
|
|
5143
|
+
} else {
|
|
5144
|
+
value = 1;
|
|
5145
|
+
for (i=0 ; i<context_numBits ; i++) {
|
|
5146
|
+
context_data_val = (context_data_val << 1) | value;
|
|
5147
|
+
if (context_data_position == bitsPerChar-1) {
|
|
5148
|
+
context_data_position = 0;
|
|
5149
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
5150
|
+
context_data_val = 0;
|
|
5151
|
+
} else {
|
|
5152
|
+
context_data_position++;
|
|
5153
|
+
}
|
|
5154
|
+
value = 0;
|
|
5155
|
+
}
|
|
5156
|
+
value = context_w.charCodeAt(0);
|
|
5157
|
+
for (i=0 ; i<16 ; i++) {
|
|
5158
|
+
context_data_val = (context_data_val << 1) | (value&1);
|
|
5159
|
+
if (context_data_position == bitsPerChar-1) {
|
|
5160
|
+
context_data_position = 0;
|
|
5161
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
5162
|
+
context_data_val = 0;
|
|
5163
|
+
} else {
|
|
5164
|
+
context_data_position++;
|
|
5165
|
+
}
|
|
5166
|
+
value = value >> 1;
|
|
5167
|
+
}
|
|
5168
|
+
}
|
|
5169
|
+
context_enlargeIn--;
|
|
5170
|
+
if (context_enlargeIn == 0) {
|
|
5171
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
5172
|
+
context_numBits++;
|
|
5173
|
+
}
|
|
5174
|
+
delete context_dictionaryToCreate[context_w];
|
|
5175
|
+
} else {
|
|
5176
|
+
value = context_dictionary[context_w];
|
|
5177
|
+
for (i=0 ; i<context_numBits ; i++) {
|
|
5178
|
+
context_data_val = (context_data_val << 1) | (value&1);
|
|
5179
|
+
if (context_data_position == bitsPerChar-1) {
|
|
5180
|
+
context_data_position = 0;
|
|
5181
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
5182
|
+
context_data_val = 0;
|
|
5183
|
+
} else {
|
|
5184
|
+
context_data_position++;
|
|
5185
|
+
}
|
|
5186
|
+
value = value >> 1;
|
|
5187
|
+
}
|
|
5222
5188
|
|
|
5223
|
-
Source: https://github.com/brix/crypto-js
|
|
5224
|
-
LICENSE: MIT
|
|
5225
|
-
*/
|
|
5226
5189
|
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
return function () {
|
|
5234
|
-
mz = 0x9069 * (mz & 0xffff) + (mz >> 0x10) & mask;
|
|
5235
|
-
mw = 0x4650 * (mw & 0xffff) + (mw >> 0x10) & mask;
|
|
5236
|
-
let result = (mz << 0x10) + mw & mask;
|
|
5237
|
-
result /= 0x100000000;
|
|
5238
|
-
result += 0.5;
|
|
5239
|
-
return result * (Math.random() > 0.5 ? 1 : -1);
|
|
5240
|
-
};
|
|
5241
|
-
};
|
|
5242
|
-
for (let i = 0, rcache; i < nBytes; i += 4) {
|
|
5243
|
-
let _r = r((rcache || Math.random()) * 0x100000000);
|
|
5244
|
-
rcache = _r() * 0x3ade67b7;
|
|
5245
|
-
words.push(_r() * 0x100000000 | 0);
|
|
5246
|
-
}
|
|
5247
|
-
return new CryptoJSWordArray.Set(words, nBytes);
|
|
5248
|
-
},
|
|
5249
|
-
Set: function (words, sigBytes) {
|
|
5250
|
-
words = this.words = words || [];
|
|
5251
|
-
if (sigBytes !== undefined) {
|
|
5252
|
-
this.sigBytes = sigBytes;
|
|
5253
|
-
} else {
|
|
5254
|
-
this.sigBytes = words.length * 8;
|
|
5190
|
+
}
|
|
5191
|
+
context_enlargeIn--;
|
|
5192
|
+
if (context_enlargeIn == 0) {
|
|
5193
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
5194
|
+
context_numBits++;
|
|
5195
|
+
}
|
|
5255
5196
|
}
|
|
5256
|
-
}
|
|
5257
|
-
};
|
|
5258
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (CryptoJSWordArray);
|
|
5259
5197
|
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
(
|
|
5198
|
+
// Mark the end of the stream
|
|
5199
|
+
value = 2;
|
|
5200
|
+
for (i=0 ; i<context_numBits ; i++) {
|
|
5201
|
+
context_data_val = (context_data_val << 1) | (value&1);
|
|
5202
|
+
if (context_data_position == bitsPerChar-1) {
|
|
5203
|
+
context_data_position = 0;
|
|
5204
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
5205
|
+
context_data_val = 0;
|
|
5206
|
+
} else {
|
|
5207
|
+
context_data_position++;
|
|
5208
|
+
}
|
|
5209
|
+
value = value >> 1;
|
|
5210
|
+
}
|
|
5267
5211
|
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
const WarningTypes = {};
|
|
5279
|
-
WarningTypes[WarningEnum.KEY_NOT_PROVIDED] = 'Secure LS: Key not provided. Aborting operation!';
|
|
5280
|
-
WarningTypes[WarningEnum.META_KEY_REMOVE] = `Secure LS: Meta key can not be removed
|
|
5281
|
-
unless all keys created by Secure LS are removed!`;
|
|
5282
|
-
WarningTypes[WarningEnum.DEFAULT_TEXT] = `Unexpected output`;
|
|
5283
|
-
const constants = {
|
|
5284
|
-
WarningEnum: WarningEnum,
|
|
5285
|
-
WarningTypes: WarningTypes,
|
|
5286
|
-
EncrytionTypes: {
|
|
5287
|
-
BASE64: 'base64',
|
|
5288
|
-
AES: 'aes',
|
|
5289
|
-
DES: 'des',
|
|
5290
|
-
RABBIT: 'rabbit',
|
|
5291
|
-
RC4: 'rc4'
|
|
5212
|
+
// Flush the last char
|
|
5213
|
+
while (true) {
|
|
5214
|
+
context_data_val = (context_data_val << 1);
|
|
5215
|
+
if (context_data_position == bitsPerChar-1) {
|
|
5216
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
5217
|
+
break;
|
|
5218
|
+
}
|
|
5219
|
+
else context_data_position++;
|
|
5220
|
+
}
|
|
5221
|
+
return context_data.join('');
|
|
5292
5222
|
},
|
|
5293
|
-
metaKey: '_secure__ls__metadata',
|
|
5294
|
-
secretPhrase: 's3cr3t$#@135^&*246'
|
|
5295
|
-
};
|
|
5296
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (constants);
|
|
5297
|
-
|
|
5298
|
-
/***/ },
|
|
5299
5223
|
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
"use strict";
|
|
5307
|
-
__webpack_require__.r(__webpack_exports__);
|
|
5308
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
5309
|
-
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
5310
|
-
/* harmony export */ });
|
|
5311
|
-
/*
|
|
5312
|
-
ES6 compatible port of CryptoJS - encoding
|
|
5224
|
+
decompress: function (compressed) {
|
|
5225
|
+
if (compressed == null) return "";
|
|
5226
|
+
if (compressed == "") return null;
|
|
5227
|
+
return LZString._decompress(compressed.length, 32768, function(index) { return compressed.charCodeAt(index); });
|
|
5228
|
+
},
|
|
5313
5229
|
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
let sigBytes = wordArray.sigBytes;
|
|
5323
|
-
let latin1Chars = [],
|
|
5230
|
+
_decompress: function (length, resetValue, getNextValue) {
|
|
5231
|
+
var dictionary = [],
|
|
5232
|
+
next,
|
|
5233
|
+
enlargeIn = 4,
|
|
5234
|
+
dictSize = 4,
|
|
5235
|
+
numBits = 3,
|
|
5236
|
+
entry = "",
|
|
5237
|
+
result = [],
|
|
5324
5238
|
i,
|
|
5325
|
-
|
|
5239
|
+
w,
|
|
5240
|
+
bits, resb, maxpower, power,
|
|
5241
|
+
c,
|
|
5242
|
+
data = {val:getNextValue(0), position:resetValue, index:1};
|
|
5326
5243
|
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 0xff;
|
|
5330
|
-
latin1Chars.push(String.fromCharCode(bite));
|
|
5331
|
-
}
|
|
5332
|
-
return latin1Chars.join('');
|
|
5244
|
+
for (i = 0; i < 3; i += 1) {
|
|
5245
|
+
dictionary[i] = i;
|
|
5333
5246
|
}
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5247
|
+
|
|
5248
|
+
bits = 0;
|
|
5249
|
+
maxpower = Math.pow(2,2);
|
|
5250
|
+
power=1;
|
|
5251
|
+
while (power!=maxpower) {
|
|
5252
|
+
resb = data.val & data.position;
|
|
5253
|
+
data.position >>= 1;
|
|
5254
|
+
if (data.position == 0) {
|
|
5255
|
+
data.position = resetValue;
|
|
5256
|
+
data.val = getNextValue(data.index++);
|
|
5341
5257
|
}
|
|
5258
|
+
bits |= (resb>0 ? 1 : 0) * power;
|
|
5259
|
+
power <<= 1;
|
|
5342
5260
|
}
|
|
5343
|
-
}
|
|
5344
|
-
};
|
|
5345
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (enc);
|
|
5346
5261
|
|
|
5347
|
-
|
|
5262
|
+
switch (next = bits) {
|
|
5263
|
+
case 0:
|
|
5264
|
+
bits = 0;
|
|
5265
|
+
maxpower = Math.pow(2,8);
|
|
5266
|
+
power=1;
|
|
5267
|
+
while (power!=maxpower) {
|
|
5268
|
+
resb = data.val & data.position;
|
|
5269
|
+
data.position >>= 1;
|
|
5270
|
+
if (data.position == 0) {
|
|
5271
|
+
data.position = resetValue;
|
|
5272
|
+
data.val = getNextValue(data.index++);
|
|
5273
|
+
}
|
|
5274
|
+
bits |= (resb>0 ? 1 : 0) * power;
|
|
5275
|
+
power <<= 1;
|
|
5276
|
+
}
|
|
5277
|
+
c = f(bits);
|
|
5278
|
+
break;
|
|
5279
|
+
case 1:
|
|
5280
|
+
bits = 0;
|
|
5281
|
+
maxpower = Math.pow(2,16);
|
|
5282
|
+
power=1;
|
|
5283
|
+
while (power!=maxpower) {
|
|
5284
|
+
resb = data.val & data.position;
|
|
5285
|
+
data.position >>= 1;
|
|
5286
|
+
if (data.position == 0) {
|
|
5287
|
+
data.position = resetValue;
|
|
5288
|
+
data.val = getNextValue(data.index++);
|
|
5289
|
+
}
|
|
5290
|
+
bits |= (resb>0 ? 1 : 0) * power;
|
|
5291
|
+
power <<= 1;
|
|
5292
|
+
}
|
|
5293
|
+
c = f(bits);
|
|
5294
|
+
break;
|
|
5295
|
+
case 2:
|
|
5296
|
+
return "";
|
|
5297
|
+
}
|
|
5298
|
+
dictionary[3] = c;
|
|
5299
|
+
w = c;
|
|
5300
|
+
result.push(c);
|
|
5301
|
+
while (true) {
|
|
5302
|
+
if (data.index > length) {
|
|
5303
|
+
return "";
|
|
5304
|
+
}
|
|
5348
5305
|
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5306
|
+
bits = 0;
|
|
5307
|
+
maxpower = Math.pow(2,numBits);
|
|
5308
|
+
power=1;
|
|
5309
|
+
while (power!=maxpower) {
|
|
5310
|
+
resb = data.val & data.position;
|
|
5311
|
+
data.position >>= 1;
|
|
5312
|
+
if (data.position == 0) {
|
|
5313
|
+
data.position = resetValue;
|
|
5314
|
+
data.val = getNextValue(data.index++);
|
|
5315
|
+
}
|
|
5316
|
+
bits |= (resb>0 ? 1 : 0) * power;
|
|
5317
|
+
power <<= 1;
|
|
5318
|
+
}
|
|
5354
5319
|
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5320
|
+
switch (c = bits) {
|
|
5321
|
+
case 0:
|
|
5322
|
+
bits = 0;
|
|
5323
|
+
maxpower = Math.pow(2,8);
|
|
5324
|
+
power=1;
|
|
5325
|
+
while (power!=maxpower) {
|
|
5326
|
+
resb = data.val & data.position;
|
|
5327
|
+
data.position >>= 1;
|
|
5328
|
+
if (data.position == 0) {
|
|
5329
|
+
data.position = resetValue;
|
|
5330
|
+
data.val = getNextValue(data.index++);
|
|
5331
|
+
}
|
|
5332
|
+
bits |= (resb>0 ? 1 : 0) * power;
|
|
5333
|
+
power <<= 1;
|
|
5334
|
+
}
|
|
5335
|
+
|
|
5336
|
+
dictionary[dictSize++] = f(bits);
|
|
5337
|
+
c = dictSize-1;
|
|
5338
|
+
enlargeIn--;
|
|
5339
|
+
break;
|
|
5340
|
+
case 1:
|
|
5341
|
+
bits = 0;
|
|
5342
|
+
maxpower = Math.pow(2,16);
|
|
5343
|
+
power=1;
|
|
5344
|
+
while (power!=maxpower) {
|
|
5345
|
+
resb = data.val & data.position;
|
|
5346
|
+
data.position >>= 1;
|
|
5347
|
+
if (data.position == 0) {
|
|
5348
|
+
data.position = resetValue;
|
|
5349
|
+
data.val = getNextValue(data.index++);
|
|
5350
|
+
}
|
|
5351
|
+
bits |= (resb>0 ? 1 : 0) * power;
|
|
5352
|
+
power <<= 1;
|
|
5353
|
+
}
|
|
5354
|
+
dictionary[dictSize++] = f(bits);
|
|
5355
|
+
c = dictSize-1;
|
|
5356
|
+
enlargeIn--;
|
|
5357
|
+
break;
|
|
5358
|
+
case 2:
|
|
5359
|
+
return result.join('');
|
|
5360
|
+
}
|
|
5361
|
+
|
|
5362
|
+
if (enlargeIn == 0) {
|
|
5363
|
+
enlargeIn = Math.pow(2, numBits);
|
|
5364
|
+
numBits++;
|
|
5365
|
+
}
|
|
5364
5366
|
|
|
5367
|
+
if (dictionary[c]) {
|
|
5368
|
+
entry = dictionary[c];
|
|
5369
|
+
} else {
|
|
5370
|
+
if (c === dictSize) {
|
|
5371
|
+
entry = w + w.charAt(0);
|
|
5372
|
+
} else {
|
|
5373
|
+
return null;
|
|
5374
|
+
}
|
|
5375
|
+
}
|
|
5376
|
+
result.push(entry);
|
|
5365
5377
|
|
|
5378
|
+
// Add w+entry[0] to the dictionary.
|
|
5379
|
+
dictionary[dictSize++] = w + entry.charAt(0);
|
|
5380
|
+
enlargeIn--;
|
|
5381
|
+
|
|
5382
|
+
w = entry;
|
|
5383
|
+
|
|
5384
|
+
if (enlargeIn == 0) {
|
|
5385
|
+
enlargeIn = Math.pow(2, numBits);
|
|
5386
|
+
numBits++;
|
|
5387
|
+
}
|
|
5366
5388
|
|
|
5367
|
-
const utils = {
|
|
5368
|
-
is: key => !!key,
|
|
5369
|
-
warn: (reason = _constants__WEBPACK_IMPORTED_MODULE_1__["default"].WarningEnum.DEFAULT_TEXT) => {
|
|
5370
|
-
console.warn(_constants__WEBPACK_IMPORTED_MODULE_1__["default"].WarningTypes[reason]);
|
|
5371
|
-
},
|
|
5372
|
-
generateSecretKey: () => {
|
|
5373
|
-
const salt = _WordArray__WEBPACK_IMPORTED_MODULE_2__["default"].random(128 / 8);
|
|
5374
|
-
const key128Bits = crypto_js_pbkdf2__WEBPACK_IMPORTED_MODULE_0___default()(_constants__WEBPACK_IMPORTED_MODULE_1__["default"].secretPhrase, salt, {
|
|
5375
|
-
keySize: 128 / 32
|
|
5376
|
-
});
|
|
5377
|
-
return key128Bits.toString();
|
|
5378
|
-
},
|
|
5379
|
-
getObjectFromKey: (data = [], key) => {
|
|
5380
|
-
return data.find(item => item.k === key) || {};
|
|
5381
|
-
},
|
|
5382
|
-
extractKeyNames: ({
|
|
5383
|
-
keys = []
|
|
5384
|
-
} = {}) => {
|
|
5385
|
-
return keys.map(({
|
|
5386
|
-
k
|
|
5387
|
-
}) => k);
|
|
5388
|
-
},
|
|
5389
|
-
isKeyPresent: (allKeys = [], key) => {
|
|
5390
|
-
return allKeys.some(item => String(item.k) === String(key));
|
|
5391
|
-
},
|
|
5392
|
-
removeFromKeysList: (allKeys = [], key) => {
|
|
5393
|
-
const index = allKeys.findIndex(item => item.k === key);
|
|
5394
|
-
if (index !== -1) {
|
|
5395
|
-
allKeys.splice(index, 1);
|
|
5396
5389
|
}
|
|
5397
|
-
return index;
|
|
5398
5390
|
}
|
|
5399
5391
|
};
|
|
5400
|
-
|
|
5392
|
+
return LZString;
|
|
5393
|
+
})();
|
|
5394
|
+
|
|
5395
|
+
if (true) {
|
|
5396
|
+
!(__WEBPACK_AMD_DEFINE_RESULT__ = (function () { return LZString; }).call(exports, __webpack_require__, exports, module),
|
|
5397
|
+
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
|
5398
|
+
} else // removed by dead control flow
|
|
5399
|
+
{}
|
|
5400
|
+
|
|
5401
5401
|
|
|
5402
5402
|
/***/ },
|
|
5403
5403
|
|