light-h5-core-lib 2.7.1 → 2.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LightCore.js +38 -35
- package/common/base/BaseSingleton.js +23 -16
- package/common/base/IClear.js +2 -2
- package/common/base/IDestroy.js +2 -2
- package/common/md5/MD5.js +346 -0
- package/common/util/BeizerUtil.js +83 -83
- package/common/util/BitUtil.js +43 -43
- package/common/util/CryptUtil.js +41 -45
- package/common/util/DateUtil.js +89 -89
- package/common/util/FloatDigitUtil.js +22 -22
- package/common/util/RandomNumUtil.js +40 -40
- package/common/util/StringUtil.js +81 -81
- package/common/util/UniqueIDUtil.js +21 -21
- package/package.json +18 -18
- package/pool/PoolObj.js +79 -79
- package/type/index.d.ts +46 -15
package/LightCore.js
CHANGED
|
@@ -1,35 +1,38 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CryptUtil = exports.BeizerUtil = exports.UniqueIDUtil = exports.StringUtil = exports.RandomNumUtil = exports.FloatDigitUtil = exports.DateUtil = exports.BitUtil = exports.BaseSingleton = exports.PoolObj = void 0;
|
|
4
|
-
var PoolObj_1 = require("./pool/PoolObj");
|
|
5
|
-
Object.defineProperty(exports, "PoolObj", { enumerable: true, get: function () { return PoolObj_1.PoolObj; } });
|
|
6
|
-
var BaseSingleton_1 = require("./common/base/BaseSingleton");
|
|
7
|
-
Object.defineProperty(exports, "BaseSingleton", { enumerable: true, get: function () { return BaseSingleton_1.BaseSingleton; } });
|
|
8
|
-
var BitUtil_1 = require("./common/util/BitUtil");
|
|
9
|
-
Object.defineProperty(exports, "BitUtil", { enumerable: true, get: function () { return BitUtil_1.BitUtil; } });
|
|
10
|
-
var DateUtil_1 = require("./common/util/DateUtil");
|
|
11
|
-
Object.defineProperty(exports, "DateUtil", { enumerable: true, get: function () { return DateUtil_1.DateUtil; } });
|
|
12
|
-
var FloatDigitUtil_1 = require("./common/util/FloatDigitUtil");
|
|
13
|
-
Object.defineProperty(exports, "FloatDigitUtil", { enumerable: true, get: function () { return FloatDigitUtil_1.FloatDigitUtil; } });
|
|
14
|
-
var RandomNumUtil_1 = require("./common/util/RandomNumUtil");
|
|
15
|
-
Object.defineProperty(exports, "RandomNumUtil", { enumerable: true, get: function () { return RandomNumUtil_1.RandomNumUtil; } });
|
|
16
|
-
var StringUtil_1 = require("./common/util/StringUtil");
|
|
17
|
-
Object.defineProperty(exports, "StringUtil", { enumerable: true, get: function () { return StringUtil_1.StringUtil; } });
|
|
18
|
-
var UniqueIDUtil_1 = require("./common/util/UniqueIDUtil");
|
|
19
|
-
Object.defineProperty(exports, "UniqueIDUtil", { enumerable: true, get: function () { return UniqueIDUtil_1.UniqueIDUtil; } });
|
|
20
|
-
var BeizerUtil_1 = require("./common/util/BeizerUtil");
|
|
21
|
-
Object.defineProperty(exports, "BeizerUtil", { enumerable: true, get: function () { return BeizerUtil_1.BeizerUtil; } });
|
|
22
|
-
var CryptUtil_1 = require("./common/util/CryptUtil");
|
|
23
|
-
Object.defineProperty(exports, "CryptUtil", { enumerable: true, get: function () { return CryptUtil_1.CryptUtil; } });
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CryptUtil = exports.BeizerUtil = exports.UniqueIDUtil = exports.StringUtil = exports.RandomNumUtil = exports.FloatDigitUtil = exports.DateUtil = exports.BitUtil = exports.MD5 = exports.BaseSingleton = exports.PoolObj = void 0;
|
|
4
|
+
var PoolObj_1 = require("./pool/PoolObj");
|
|
5
|
+
Object.defineProperty(exports, "PoolObj", { enumerable: true, get: function () { return PoolObj_1.PoolObj; } });
|
|
6
|
+
var BaseSingleton_1 = require("./common/base/BaseSingleton");
|
|
7
|
+
Object.defineProperty(exports, "BaseSingleton", { enumerable: true, get: function () { return BaseSingleton_1.BaseSingleton; } });
|
|
8
|
+
var BitUtil_1 = require("./common/util/BitUtil");
|
|
9
|
+
Object.defineProperty(exports, "BitUtil", { enumerable: true, get: function () { return BitUtil_1.BitUtil; } });
|
|
10
|
+
var DateUtil_1 = require("./common/util/DateUtil");
|
|
11
|
+
Object.defineProperty(exports, "DateUtil", { enumerable: true, get: function () { return DateUtil_1.DateUtil; } });
|
|
12
|
+
var FloatDigitUtil_1 = require("./common/util/FloatDigitUtil");
|
|
13
|
+
Object.defineProperty(exports, "FloatDigitUtil", { enumerable: true, get: function () { return FloatDigitUtil_1.FloatDigitUtil; } });
|
|
14
|
+
var RandomNumUtil_1 = require("./common/util/RandomNumUtil");
|
|
15
|
+
Object.defineProperty(exports, "RandomNumUtil", { enumerable: true, get: function () { return RandomNumUtil_1.RandomNumUtil; } });
|
|
16
|
+
var StringUtil_1 = require("./common/util/StringUtil");
|
|
17
|
+
Object.defineProperty(exports, "StringUtil", { enumerable: true, get: function () { return StringUtil_1.StringUtil; } });
|
|
18
|
+
var UniqueIDUtil_1 = require("./common/util/UniqueIDUtil");
|
|
19
|
+
Object.defineProperty(exports, "UniqueIDUtil", { enumerable: true, get: function () { return UniqueIDUtil_1.UniqueIDUtil; } });
|
|
20
|
+
var BeizerUtil_1 = require("./common/util/BeizerUtil");
|
|
21
|
+
Object.defineProperty(exports, "BeizerUtil", { enumerable: true, get: function () { return BeizerUtil_1.BeizerUtil; } });
|
|
22
|
+
var CryptUtil_1 = require("./common/util/CryptUtil");
|
|
23
|
+
Object.defineProperty(exports, "CryptUtil", { enumerable: true, get: function () { return CryptUtil_1.CryptUtil; } });
|
|
24
|
+
var MD5_1 = require("./common/md5/MD5");
|
|
25
|
+
Object.defineProperty(exports, "MD5", { enumerable: true, get: function () { return MD5_1.MD5; } });
|
|
26
|
+
module.exports = {
|
|
27
|
+
PoolObj: PoolObj_1.PoolObj,
|
|
28
|
+
BaseSingleton: BaseSingleton_1.BaseSingleton,
|
|
29
|
+
MD5: MD5_1.MD5,
|
|
30
|
+
BitUtil: BitUtil_1.BitUtil,
|
|
31
|
+
DateUtil: DateUtil_1.DateUtil,
|
|
32
|
+
FloatDigitUtil: FloatDigitUtil_1.FloatDigitUtil,
|
|
33
|
+
RandomNumUtil: RandomNumUtil_1.RandomNumUtil,
|
|
34
|
+
StringUtil: StringUtil_1.StringUtil,
|
|
35
|
+
UniqueIDUtil: UniqueIDUtil_1.UniqueIDUtil,
|
|
36
|
+
BeizerUtil: BeizerUtil_1.BeizerUtil,
|
|
37
|
+
CryptUtil: CryptUtil_1.CryptUtil,
|
|
38
|
+
};
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseSingleton = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseSingleton = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 泛型单例基类
|
|
6
|
+
* @author Aonaufly
|
|
7
|
+
*/
|
|
8
|
+
var BaseSingleton = /** @class */ (function () {
|
|
9
|
+
function BaseSingleton() {
|
|
10
|
+
}
|
|
11
|
+
BaseSingleton.getInstance = function (c) {
|
|
12
|
+
if (this._instance == null) {
|
|
13
|
+
this._instance = new c();
|
|
14
|
+
}
|
|
15
|
+
return this._instance;
|
|
16
|
+
};
|
|
17
|
+
BaseSingleton.prototype.destroy = function () {
|
|
18
|
+
BaseSingleton._instance = null;
|
|
19
|
+
};
|
|
20
|
+
BaseSingleton._instance = null;
|
|
21
|
+
return BaseSingleton;
|
|
22
|
+
}());
|
|
23
|
+
exports.BaseSingleton = BaseSingleton;
|
package/common/base/IClear.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/common/base/IDestroy.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.MD5 = void 0;
|
|
19
|
+
var BaseSingleton_1 = require("../base/BaseSingleton");
|
|
20
|
+
var MD5 = /** @class */ (function (_super) {
|
|
21
|
+
__extends(MD5, _super);
|
|
22
|
+
function MD5() {
|
|
23
|
+
var _this = _super.call(this) || this;
|
|
24
|
+
_this.hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
|
|
25
|
+
_this.b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
/*
|
|
29
|
+
* These are the privates you'll usually want to call
|
|
30
|
+
* They take string arguments and return either hex or base-64 encoded strings
|
|
31
|
+
*/
|
|
32
|
+
MD5.prototype.hex_md5 = function (s) {
|
|
33
|
+
return this.rstr2hex(this.rstr_md5(this.str2rstr_utf8(s)));
|
|
34
|
+
}; //这个函数就行了,
|
|
35
|
+
MD5.prototype.b64_md5 = function (s) {
|
|
36
|
+
return this.rstr2b64(this.rstr_md5(this.str2rstr_utf8(s)));
|
|
37
|
+
};
|
|
38
|
+
MD5.prototype.any_md5 = function (s, e) {
|
|
39
|
+
return this.rstr2any(this.rstr_md5(this.str2rstr_utf8(s)), e);
|
|
40
|
+
};
|
|
41
|
+
MD5.prototype.hex_hmac_md5 = function (k, d) {
|
|
42
|
+
return this.rstr2hex(this.rstr_hmac_md5(this.str2rstr_utf8(k), this.str2rstr_utf8(d)));
|
|
43
|
+
};
|
|
44
|
+
MD5.prototype.b64_hmac_md5 = function (k, d) {
|
|
45
|
+
return this.rstr2b64(this.rstr_hmac_md5(this.str2rstr_utf8(k), this.str2rstr_utf8(d)));
|
|
46
|
+
};
|
|
47
|
+
MD5.prototype.any_hmac_md5 = function (k, d, e) {
|
|
48
|
+
return this.rstr2any(this.rstr_hmac_md5(this.str2rstr_utf8(k), this.str2rstr_utf8(d)), e);
|
|
49
|
+
};
|
|
50
|
+
/*
|
|
51
|
+
* Perform a simple self-test to see if the VM is working
|
|
52
|
+
*/
|
|
53
|
+
MD5.prototype.md5_vm_test = function () {
|
|
54
|
+
return this.hex_md5("abc").toLowerCase() == "900150983cd24fb0d6963f7d28e17f72";
|
|
55
|
+
};
|
|
56
|
+
/*
|
|
57
|
+
* Calculate the MD5 of a raw string
|
|
58
|
+
*/
|
|
59
|
+
MD5.prototype.rstr_md5 = function (s) {
|
|
60
|
+
return this.binl2rstr(this.binl_md5(this.rstr2binl(s), s.length * 8));
|
|
61
|
+
};
|
|
62
|
+
/*
|
|
63
|
+
* Calculate the HMAC-MD5, of a key and some data (raw strings)
|
|
64
|
+
*/
|
|
65
|
+
MD5.prototype.rstr_hmac_md5 = function (key, data) {
|
|
66
|
+
var bkey = this.rstr2binl(key);
|
|
67
|
+
if (bkey.length > 16)
|
|
68
|
+
bkey = this.binl_md5(bkey, key.length * 8);
|
|
69
|
+
var ipad = Array(16), opad = Array(16);
|
|
70
|
+
for (var i = 0; i < 16; i++) {
|
|
71
|
+
ipad[i] = bkey[i] ^ 0x36363636;
|
|
72
|
+
opad[i] = bkey[i] ^ 0x5c5c5c5c;
|
|
73
|
+
}
|
|
74
|
+
var hash = this.binl_md5(ipad.concat(this.rstr2binl(data)), 512 + data.length * 8);
|
|
75
|
+
return this.binl2rstr(this.binl_md5(opad.concat(hash), 512 + 128));
|
|
76
|
+
};
|
|
77
|
+
/*
|
|
78
|
+
* Convert a raw string to a hex string
|
|
79
|
+
*/
|
|
80
|
+
MD5.prototype.rstr2hex = function (input) {
|
|
81
|
+
try {
|
|
82
|
+
this.hexcase;
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
this.hexcase = 0;
|
|
86
|
+
}
|
|
87
|
+
var hex_tab = this.hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
|
|
88
|
+
var output = "";
|
|
89
|
+
var x;
|
|
90
|
+
for (var i = 0; i < input.length; i++) {
|
|
91
|
+
x = input.charCodeAt(i);
|
|
92
|
+
output += hex_tab.charAt((x >>> 4) & 0x0f) + hex_tab.charAt(x & 0x0f);
|
|
93
|
+
}
|
|
94
|
+
return output;
|
|
95
|
+
};
|
|
96
|
+
/*
|
|
97
|
+
* Convert a raw string to a base-64 string
|
|
98
|
+
*/
|
|
99
|
+
MD5.prototype.rstr2b64 = function (input) {
|
|
100
|
+
try {
|
|
101
|
+
this.b64pad;
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
this.b64pad = "";
|
|
105
|
+
}
|
|
106
|
+
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
107
|
+
var output = "";
|
|
108
|
+
var len = input.length;
|
|
109
|
+
for (var i = 0; i < len; i += 3) {
|
|
110
|
+
var triplet = (input.charCodeAt(i) << 16) |
|
|
111
|
+
(i + 1 < len ? input.charCodeAt(i + 1) << 8 : 0) |
|
|
112
|
+
(i + 2 < len ? input.charCodeAt(i + 2) : 0);
|
|
113
|
+
for (var j = 0; j < 4; j++) {
|
|
114
|
+
if (i * 8 + j * 6 > input.length * 8)
|
|
115
|
+
output += this.b64pad;
|
|
116
|
+
else
|
|
117
|
+
output += tab.charAt((triplet >>> (6 * (3 - j))) & 0x3f);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return output;
|
|
121
|
+
};
|
|
122
|
+
/*
|
|
123
|
+
* Convert a raw string to an arbitrary string encoding
|
|
124
|
+
*/
|
|
125
|
+
MD5.prototype.rstr2any = function (input, encoding) {
|
|
126
|
+
var divisor = encoding.length;
|
|
127
|
+
var i, j, q, x, quotient;
|
|
128
|
+
/* Convert to an array of 16-bit big-endian values, forming the dividend */
|
|
129
|
+
var dividend = Array(Math.ceil(input.length / 2));
|
|
130
|
+
for (i = 0; i < dividend.length; i++) {
|
|
131
|
+
dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
|
|
132
|
+
}
|
|
133
|
+
/*
|
|
134
|
+
* Repeatedly perform a long division. The binary array forms the dividend,
|
|
135
|
+
* the length of the encoding is the divisor. Once computed, the quotient
|
|
136
|
+
* forms the dividend for the next step. All remainders are stored for later
|
|
137
|
+
* use.
|
|
138
|
+
*/
|
|
139
|
+
var full_length = Math.ceil((input.length * 8) / (Math.log(encoding.length) / Math.log(2)));
|
|
140
|
+
var remainders = Array(full_length);
|
|
141
|
+
for (j = 0; j < full_length; j++) {
|
|
142
|
+
quotient = Array();
|
|
143
|
+
x = 0;
|
|
144
|
+
for (i = 0; i < dividend.length; i++) {
|
|
145
|
+
x = (x << 16) + dividend[i];
|
|
146
|
+
q = Math.floor(x / divisor);
|
|
147
|
+
x -= q * divisor;
|
|
148
|
+
if (quotient.length > 0 || q > 0)
|
|
149
|
+
quotient[quotient.length] = q;
|
|
150
|
+
}
|
|
151
|
+
remainders[j] = x;
|
|
152
|
+
dividend = quotient;
|
|
153
|
+
}
|
|
154
|
+
/* Convert the remainders to the output string */
|
|
155
|
+
var output = "";
|
|
156
|
+
for (i = remainders.length - 1; i >= 0; i--)
|
|
157
|
+
output += encoding.charAt(remainders[i]);
|
|
158
|
+
return output;
|
|
159
|
+
};
|
|
160
|
+
/*
|
|
161
|
+
* Encode a string as utf-8.
|
|
162
|
+
* For efficiency, this assumes the input is valid utf-16.
|
|
163
|
+
*/
|
|
164
|
+
MD5.prototype.str2rstr_utf8 = function (input) {
|
|
165
|
+
var output = "";
|
|
166
|
+
var i = -1;
|
|
167
|
+
var x, y;
|
|
168
|
+
while (++i < input.length) {
|
|
169
|
+
/* Decode utf-16 surrogate pairs */
|
|
170
|
+
x = input.charCodeAt(i);
|
|
171
|
+
y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
|
|
172
|
+
if (0xd800 <= x && x <= 0xdbff && 0xdc00 <= y && y <= 0xdfff) {
|
|
173
|
+
x = 0x10000 + ((x & 0x03ff) << 10) + (y & 0x03ff);
|
|
174
|
+
i++;
|
|
175
|
+
}
|
|
176
|
+
/* Encode output as utf-8 */
|
|
177
|
+
if (x <= 0x7f)
|
|
178
|
+
output += String.fromCharCode(x);
|
|
179
|
+
else if (x <= 0x7ff)
|
|
180
|
+
output += String.fromCharCode(0xc0 | ((x >>> 6) & 0x1f), 0x80 | (x & 0x3f));
|
|
181
|
+
else if (x <= 0xffff)
|
|
182
|
+
output += String.fromCharCode(0xe0 | ((x >>> 12) & 0x0f), 0x80 | ((x >>> 6) & 0x3f), 0x80 | (x & 0x3f));
|
|
183
|
+
else if (x <= 0x1fffff)
|
|
184
|
+
output += String.fromCharCode(0xf0 | ((x >>> 18) & 0x07), 0x80 | ((x >>> 12) & 0x3f), 0x80 | ((x >>> 6) & 0x3f), 0x80 | (x & 0x3f));
|
|
185
|
+
}
|
|
186
|
+
return output;
|
|
187
|
+
};
|
|
188
|
+
/*
|
|
189
|
+
* Encode a string as utf-16
|
|
190
|
+
*/
|
|
191
|
+
MD5.prototype.str2rstr_utf16le = function (input) {
|
|
192
|
+
var output = "";
|
|
193
|
+
for (var i = 0; i < input.length; i++)
|
|
194
|
+
output += String.fromCharCode(input.charCodeAt(i) & 0xff, (input.charCodeAt(i) >>> 8) & 0xff);
|
|
195
|
+
return output;
|
|
196
|
+
};
|
|
197
|
+
MD5.prototype.str2rstr_utf16be = function (input) {
|
|
198
|
+
var output = "";
|
|
199
|
+
for (var i = 0; i < input.length; i++)
|
|
200
|
+
output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xff, input.charCodeAt(i) & 0xff);
|
|
201
|
+
return output;
|
|
202
|
+
};
|
|
203
|
+
/*
|
|
204
|
+
* Convert a raw string to an array of little-endian words
|
|
205
|
+
* Characters >255 have their high-byte silently ignored.
|
|
206
|
+
*/
|
|
207
|
+
MD5.prototype.rstr2binl = function (input) {
|
|
208
|
+
var output = Array(input.length >> 2);
|
|
209
|
+
for (var i = 0; i < output.length; i++)
|
|
210
|
+
output[i] = 0;
|
|
211
|
+
for (var i = 0; i < input.length * 8; i += 8)
|
|
212
|
+
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << i % 32;
|
|
213
|
+
return output;
|
|
214
|
+
};
|
|
215
|
+
/*
|
|
216
|
+
* Convert an array of little-endian words to a string
|
|
217
|
+
*/
|
|
218
|
+
MD5.prototype.binl2rstr = function (input) {
|
|
219
|
+
var output = "";
|
|
220
|
+
for (var i = 0; i < input.length * 32; i += 8)
|
|
221
|
+
output += String.fromCharCode((input[i >> 5] >>> i % 32) & 0xff);
|
|
222
|
+
return output;
|
|
223
|
+
};
|
|
224
|
+
/*
|
|
225
|
+
* Calculate the MD5 of an array of little-endian words, and a bit length.
|
|
226
|
+
*/
|
|
227
|
+
MD5.prototype.binl_md5 = function (x, len) {
|
|
228
|
+
/* append padding */
|
|
229
|
+
x[len >> 5] |= 0x80 << len % 32;
|
|
230
|
+
x[(((len + 64) >>> 9) << 4) + 14] = len;
|
|
231
|
+
var a = 1732584193;
|
|
232
|
+
var b = -271733879;
|
|
233
|
+
var c = -1732584194;
|
|
234
|
+
var d = 271733878;
|
|
235
|
+
for (var i = 0; i < x.length; i += 16) {
|
|
236
|
+
var olda = a;
|
|
237
|
+
var oldb = b;
|
|
238
|
+
var oldc = c;
|
|
239
|
+
var oldd = d;
|
|
240
|
+
a = this.md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
|
|
241
|
+
d = this.md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
|
|
242
|
+
c = this.md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
|
|
243
|
+
b = this.md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
|
|
244
|
+
a = this.md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
|
|
245
|
+
d = this.md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
|
|
246
|
+
c = this.md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
|
|
247
|
+
b = this.md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
|
|
248
|
+
a = this.md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
|
|
249
|
+
d = this.md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
|
|
250
|
+
c = this.md5_ff(c, d, a, b, x[i + 10], 17, -42063);
|
|
251
|
+
b = this.md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
|
|
252
|
+
a = this.md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
|
|
253
|
+
d = this.md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
|
|
254
|
+
c = this.md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
|
|
255
|
+
b = this.md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
|
|
256
|
+
a = this.md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
|
|
257
|
+
d = this.md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
|
|
258
|
+
c = this.md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
|
|
259
|
+
b = this.md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
|
|
260
|
+
a = this.md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
|
|
261
|
+
d = this.md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
|
|
262
|
+
c = this.md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
|
|
263
|
+
b = this.md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
|
|
264
|
+
a = this.md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
|
|
265
|
+
d = this.md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
|
|
266
|
+
c = this.md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
|
|
267
|
+
b = this.md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
|
|
268
|
+
a = this.md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
|
|
269
|
+
d = this.md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
|
|
270
|
+
c = this.md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
|
|
271
|
+
b = this.md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
|
|
272
|
+
a = this.md5_hh(a, b, c, d, x[i + 5], 4, -378558);
|
|
273
|
+
d = this.md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
|
|
274
|
+
c = this.md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
|
|
275
|
+
b = this.md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
|
|
276
|
+
a = this.md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
|
|
277
|
+
d = this.md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
|
|
278
|
+
c = this.md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
|
|
279
|
+
b = this.md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
|
|
280
|
+
a = this.md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
|
|
281
|
+
d = this.md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
|
|
282
|
+
c = this.md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
|
|
283
|
+
b = this.md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
|
|
284
|
+
a = this.md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
|
|
285
|
+
d = this.md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
|
|
286
|
+
c = this.md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
|
|
287
|
+
b = this.md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
|
|
288
|
+
a = this.md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
|
|
289
|
+
d = this.md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
|
|
290
|
+
c = this.md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
|
|
291
|
+
b = this.md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
|
|
292
|
+
a = this.md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
|
|
293
|
+
d = this.md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
|
|
294
|
+
c = this.md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
|
|
295
|
+
b = this.md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
|
|
296
|
+
a = this.md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
|
|
297
|
+
d = this.md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
|
|
298
|
+
c = this.md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
|
|
299
|
+
b = this.md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
|
|
300
|
+
a = this.md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
|
|
301
|
+
d = this.md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
|
|
302
|
+
c = this.md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
|
|
303
|
+
b = this.md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
|
|
304
|
+
a = this.safe_add(a, olda);
|
|
305
|
+
b = this.safe_add(b, oldb);
|
|
306
|
+
c = this.safe_add(c, oldc);
|
|
307
|
+
d = this.safe_add(d, oldd);
|
|
308
|
+
}
|
|
309
|
+
return [a, b, c, d];
|
|
310
|
+
};
|
|
311
|
+
/*
|
|
312
|
+
* These privates implement the four basic operations the algorithm uses.
|
|
313
|
+
*/
|
|
314
|
+
MD5.prototype.md5_cmn = function (q, a, b, x, s, t) {
|
|
315
|
+
return this.safe_add(this.bit_rol(this.safe_add(this.safe_add(a, q), this.safe_add(x, t)), s), b);
|
|
316
|
+
};
|
|
317
|
+
MD5.prototype.md5_ff = function (a, b, c, d, x, s, t) {
|
|
318
|
+
return this.md5_cmn((b & c) | (~b & d), a, b, x, s, t);
|
|
319
|
+
};
|
|
320
|
+
MD5.prototype.md5_gg = function (a, b, c, d, x, s, t) {
|
|
321
|
+
return this.md5_cmn((b & d) | (c & ~d), a, b, x, s, t);
|
|
322
|
+
};
|
|
323
|
+
MD5.prototype.md5_hh = function (a, b, c, d, x, s, t) {
|
|
324
|
+
return this.md5_cmn(b ^ c ^ d, a, b, x, s, t);
|
|
325
|
+
};
|
|
326
|
+
MD5.prototype.md5_ii = function (a, b, c, d, x, s, t) {
|
|
327
|
+
return this.md5_cmn(c ^ (b | ~d), a, b, x, s, t);
|
|
328
|
+
};
|
|
329
|
+
/*
|
|
330
|
+
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
|
331
|
+
* to work around bugs in some JS interpreters.
|
|
332
|
+
*/
|
|
333
|
+
MD5.prototype.safe_add = function (x, y) {
|
|
334
|
+
var lsw = (x & 0xffff) + (y & 0xffff);
|
|
335
|
+
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
|
336
|
+
return (msw << 16) | (lsw & 0xffff);
|
|
337
|
+
};
|
|
338
|
+
/*
|
|
339
|
+
* Bitwise rotate a 32-bit number to the left.
|
|
340
|
+
*/
|
|
341
|
+
MD5.prototype.bit_rol = function (num, cnt) {
|
|
342
|
+
return (num << cnt) | (num >>> (32 - cnt));
|
|
343
|
+
};
|
|
344
|
+
return MD5;
|
|
345
|
+
}(BaseSingleton_1.BaseSingleton));
|
|
346
|
+
exports.MD5 = MD5;
|
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BeizerUtil = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 贝塞尔曲线运动
|
|
6
|
-
* @author Aonaufly
|
|
7
|
-
*/
|
|
8
|
-
var BeizerUtil = /** @class */ (function () {
|
|
9
|
-
function BeizerUtil() {
|
|
10
|
-
}
|
|
11
|
-
//#region 获得当前坐标
|
|
12
|
-
/**
|
|
13
|
-
* 获得当前坐标
|
|
14
|
-
* @param timer 时间[0,1]
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
17
|
-
BeizerUtil.getPosition = function (points, timer) {
|
|
18
|
-
var x = 0, y = 0;
|
|
19
|
-
var bezier;
|
|
20
|
-
for (var i = 0, n = points.length; i < n; i++) {
|
|
21
|
-
bezier =
|
|
22
|
-
Math.min(Math.pow(1 - timer, n - i - 1) * Math.pow(timer, i)) *
|
|
23
|
-
BeizerUtil.calculationC(i, n);
|
|
24
|
-
x += points[i].x * bezier;
|
|
25
|
-
y += points[i].y * bezier;
|
|
26
|
-
}
|
|
27
|
-
return { x: x, y: y };
|
|
28
|
-
};
|
|
29
|
-
//#endregion
|
|
30
|
-
//region 获得路线的长度
|
|
31
|
-
BeizerUtil.distance = function (p1, p2) {
|
|
32
|
-
var dx = p2.x - p1.x;
|
|
33
|
-
var dy = p2.y - p1.y;
|
|
34
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* 获得整个路线的长度
|
|
38
|
-
* @param precision 精确度(微积分方案)
|
|
39
|
-
*/
|
|
40
|
-
BeizerUtil.getLength = function (points, precision) {
|
|
41
|
-
if (precision === void 0) { precision = 100; }
|
|
42
|
-
var length = 0;
|
|
43
|
-
var point1;
|
|
44
|
-
var point2;
|
|
45
|
-
for (var t = 0; t < 1; t += 1 / precision) {
|
|
46
|
-
point1 = BeizerUtil.getBezierPoint(points, t);
|
|
47
|
-
point2 = BeizerUtil.getBezierPoint(points, t + 1 / precision);
|
|
48
|
-
length += BeizerUtil.distance(point1, point2);
|
|
49
|
-
}
|
|
50
|
-
return length;
|
|
51
|
-
};
|
|
52
|
-
BeizerUtil.calculationC = function (i, n) {
|
|
53
|
-
return (BeizerUtil.factorial(n - 1) /
|
|
54
|
-
(BeizerUtil.factorial(i) * BeizerUtil.factorial(n - 1 - i)));
|
|
55
|
-
};
|
|
56
|
-
BeizerUtil.factorial = function (num) {
|
|
57
|
-
if (num < 0) {
|
|
58
|
-
return 1;
|
|
59
|
-
}
|
|
60
|
-
else if (num === 0 || num === 1) {
|
|
61
|
-
return 1;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
return num * BeizerUtil.factorial(num - 1);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
BeizerUtil.getBezierPoint = function (points, t) {
|
|
68
|
-
if (points.length === 1) {
|
|
69
|
-
return points[0];
|
|
70
|
-
}
|
|
71
|
-
var nextPoints = [];
|
|
72
|
-
var x;
|
|
73
|
-
var y;
|
|
74
|
-
for (var i = 0; i < points.length - 1; i++) {
|
|
75
|
-
x = (1 - t) * points[i].x + t * points[i + 1].x;
|
|
76
|
-
y = (1 - t) * points[i].y + t * points[i + 1].y;
|
|
77
|
-
nextPoints.push({ x: x, y: y });
|
|
78
|
-
}
|
|
79
|
-
return BeizerUtil.getBezierPoint(nextPoints, t);
|
|
80
|
-
};
|
|
81
|
-
return BeizerUtil;
|
|
82
|
-
}());
|
|
83
|
-
exports.BeizerUtil = BeizerUtil;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BeizerUtil = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 贝塞尔曲线运动
|
|
6
|
+
* @author Aonaufly
|
|
7
|
+
*/
|
|
8
|
+
var BeizerUtil = /** @class */ (function () {
|
|
9
|
+
function BeizerUtil() {
|
|
10
|
+
}
|
|
11
|
+
//#region 获得当前坐标
|
|
12
|
+
/**
|
|
13
|
+
* 获得当前坐标
|
|
14
|
+
* @param timer 时间[0,1]
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
BeizerUtil.getPosition = function (points, timer) {
|
|
18
|
+
var x = 0, y = 0;
|
|
19
|
+
var bezier;
|
|
20
|
+
for (var i = 0, n = points.length; i < n; i++) {
|
|
21
|
+
bezier =
|
|
22
|
+
Math.min(Math.pow(1 - timer, n - i - 1) * Math.pow(timer, i)) *
|
|
23
|
+
BeizerUtil.calculationC(i, n);
|
|
24
|
+
x += points[i].x * bezier;
|
|
25
|
+
y += points[i].y * bezier;
|
|
26
|
+
}
|
|
27
|
+
return { x: x, y: y };
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
//region 获得路线的长度
|
|
31
|
+
BeizerUtil.distance = function (p1, p2) {
|
|
32
|
+
var dx = p2.x - p1.x;
|
|
33
|
+
var dy = p2.y - p1.y;
|
|
34
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 获得整个路线的长度
|
|
38
|
+
* @param precision 精确度(微积分方案)
|
|
39
|
+
*/
|
|
40
|
+
BeizerUtil.getLength = function (points, precision) {
|
|
41
|
+
if (precision === void 0) { precision = 100; }
|
|
42
|
+
var length = 0;
|
|
43
|
+
var point1;
|
|
44
|
+
var point2;
|
|
45
|
+
for (var t = 0; t < 1; t += 1 / precision) {
|
|
46
|
+
point1 = BeizerUtil.getBezierPoint(points, t);
|
|
47
|
+
point2 = BeizerUtil.getBezierPoint(points, t + 1 / precision);
|
|
48
|
+
length += BeizerUtil.distance(point1, point2);
|
|
49
|
+
}
|
|
50
|
+
return length;
|
|
51
|
+
};
|
|
52
|
+
BeizerUtil.calculationC = function (i, n) {
|
|
53
|
+
return (BeizerUtil.factorial(n - 1) /
|
|
54
|
+
(BeizerUtil.factorial(i) * BeizerUtil.factorial(n - 1 - i)));
|
|
55
|
+
};
|
|
56
|
+
BeizerUtil.factorial = function (num) {
|
|
57
|
+
if (num < 0) {
|
|
58
|
+
return 1;
|
|
59
|
+
}
|
|
60
|
+
else if (num === 0 || num === 1) {
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return num * BeizerUtil.factorial(num - 1);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
BeizerUtil.getBezierPoint = function (points, t) {
|
|
68
|
+
if (points.length === 1) {
|
|
69
|
+
return points[0];
|
|
70
|
+
}
|
|
71
|
+
var nextPoints = [];
|
|
72
|
+
var x;
|
|
73
|
+
var y;
|
|
74
|
+
for (var i = 0; i < points.length - 1; i++) {
|
|
75
|
+
x = (1 - t) * points[i].x + t * points[i + 1].x;
|
|
76
|
+
y = (1 - t) * points[i].y + t * points[i + 1].y;
|
|
77
|
+
nextPoints.push({ x: x, y: y });
|
|
78
|
+
}
|
|
79
|
+
return BeizerUtil.getBezierPoint(nextPoints, t);
|
|
80
|
+
};
|
|
81
|
+
return BeizerUtil;
|
|
82
|
+
}());
|
|
83
|
+
exports.BeizerUtil = BeizerUtil;
|