qjutil 0.0.7 → 0.0.8
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/dist/index.d.ts +2 -2
- package/dist/index.global.js +314 -114
- package/dist/index.js +2 -1
- package/package.json +11 -17
package/dist/index.d.ts
CHANGED
package/dist/index.global.js
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
(() => {
|
|
2
|
+
var qjutil = (() => {
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
7
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
10
|
};
|
|
9
|
-
var
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
default: () => index_default,
|
|
25
|
+
sign: () => sign_exports
|
|
26
|
+
});
|
|
10
27
|
|
|
11
28
|
// src/util/sign.ts
|
|
12
29
|
var sign_exports = {};
|
|
@@ -15,41 +32,188 @@
|
|
|
15
32
|
raw: () => raw
|
|
16
33
|
});
|
|
17
34
|
|
|
18
|
-
// node_modules/ts-md5/dist/
|
|
19
|
-
var
|
|
20
|
-
var _h = class _h {
|
|
35
|
+
// node_modules/ts-md5/dist/esm/md5.js
|
|
36
|
+
var Md5 = class _Md5 {
|
|
21
37
|
constructor() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.
|
|
38
|
+
this._dataLength = 0;
|
|
39
|
+
this._bufferLength = 0;
|
|
40
|
+
this._state = new Int32Array(4);
|
|
41
|
+
this._buffer = new ArrayBuffer(68);
|
|
42
|
+
this._buffer8 = new Uint8Array(this._buffer, 0, 68);
|
|
43
|
+
this._buffer32 = new Uint32Array(this._buffer, 0, 17);
|
|
44
|
+
this.start();
|
|
29
45
|
}
|
|
30
|
-
static hashStr(
|
|
31
|
-
return this.onePassHasher.start().appendStr(
|
|
46
|
+
static hashStr(str, raw2 = false) {
|
|
47
|
+
return this.onePassHasher.start().appendStr(str).end(raw2);
|
|
32
48
|
}
|
|
33
|
-
static hashAsciiStr(
|
|
34
|
-
return this.onePassHasher.start().appendAsciiStr(
|
|
49
|
+
static hashAsciiStr(str, raw2 = false) {
|
|
50
|
+
return this.onePassHasher.start().appendAsciiStr(str).end(raw2);
|
|
35
51
|
}
|
|
36
|
-
static _hex(
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
52
|
+
static _hex(x) {
|
|
53
|
+
const hc = _Md5.hexChars;
|
|
54
|
+
const ho = _Md5.hexOut;
|
|
55
|
+
let n;
|
|
56
|
+
let offset;
|
|
57
|
+
let j;
|
|
58
|
+
let i;
|
|
59
|
+
for (i = 0; i < 4; i += 1) {
|
|
60
|
+
offset = i * 8;
|
|
61
|
+
n = x[i];
|
|
62
|
+
for (j = 0; j < 8; j += 2) {
|
|
63
|
+
ho[offset + 1 + j] = hc.charAt(n & 15);
|
|
64
|
+
n >>>= 4;
|
|
65
|
+
ho[offset + 0 + j] = hc.charAt(n & 15);
|
|
66
|
+
n >>>= 4;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return ho.join("");
|
|
43
70
|
}
|
|
44
|
-
static _md5cycle(
|
|
45
|
-
let
|
|
46
|
-
|
|
71
|
+
static _md5cycle(x, k) {
|
|
72
|
+
let a = x[0];
|
|
73
|
+
let b = x[1];
|
|
74
|
+
let c = x[2];
|
|
75
|
+
let d = x[3];
|
|
76
|
+
a += (b & c | ~b & d) + k[0] - 680876936 | 0;
|
|
77
|
+
a = (a << 7 | a >>> 25) + b | 0;
|
|
78
|
+
d += (a & b | ~a & c) + k[1] - 389564586 | 0;
|
|
79
|
+
d = (d << 12 | d >>> 20) + a | 0;
|
|
80
|
+
c += (d & a | ~d & b) + k[2] + 606105819 | 0;
|
|
81
|
+
c = (c << 17 | c >>> 15) + d | 0;
|
|
82
|
+
b += (c & d | ~c & a) + k[3] - 1044525330 | 0;
|
|
83
|
+
b = (b << 22 | b >>> 10) + c | 0;
|
|
84
|
+
a += (b & c | ~b & d) + k[4] - 176418897 | 0;
|
|
85
|
+
a = (a << 7 | a >>> 25) + b | 0;
|
|
86
|
+
d += (a & b | ~a & c) + k[5] + 1200080426 | 0;
|
|
87
|
+
d = (d << 12 | d >>> 20) + a | 0;
|
|
88
|
+
c += (d & a | ~d & b) + k[6] - 1473231341 | 0;
|
|
89
|
+
c = (c << 17 | c >>> 15) + d | 0;
|
|
90
|
+
b += (c & d | ~c & a) + k[7] - 45705983 | 0;
|
|
91
|
+
b = (b << 22 | b >>> 10) + c | 0;
|
|
92
|
+
a += (b & c | ~b & d) + k[8] + 1770035416 | 0;
|
|
93
|
+
a = (a << 7 | a >>> 25) + b | 0;
|
|
94
|
+
d += (a & b | ~a & c) + k[9] - 1958414417 | 0;
|
|
95
|
+
d = (d << 12 | d >>> 20) + a | 0;
|
|
96
|
+
c += (d & a | ~d & b) + k[10] - 42063 | 0;
|
|
97
|
+
c = (c << 17 | c >>> 15) + d | 0;
|
|
98
|
+
b += (c & d | ~c & a) + k[11] - 1990404162 | 0;
|
|
99
|
+
b = (b << 22 | b >>> 10) + c | 0;
|
|
100
|
+
a += (b & c | ~b & d) + k[12] + 1804603682 | 0;
|
|
101
|
+
a = (a << 7 | a >>> 25) + b | 0;
|
|
102
|
+
d += (a & b | ~a & c) + k[13] - 40341101 | 0;
|
|
103
|
+
d = (d << 12 | d >>> 20) + a | 0;
|
|
104
|
+
c += (d & a | ~d & b) + k[14] - 1502002290 | 0;
|
|
105
|
+
c = (c << 17 | c >>> 15) + d | 0;
|
|
106
|
+
b += (c & d | ~c & a) + k[15] + 1236535329 | 0;
|
|
107
|
+
b = (b << 22 | b >>> 10) + c | 0;
|
|
108
|
+
a += (b & d | c & ~d) + k[1] - 165796510 | 0;
|
|
109
|
+
a = (a << 5 | a >>> 27) + b | 0;
|
|
110
|
+
d += (a & c | b & ~c) + k[6] - 1069501632 | 0;
|
|
111
|
+
d = (d << 9 | d >>> 23) + a | 0;
|
|
112
|
+
c += (d & b | a & ~b) + k[11] + 643717713 | 0;
|
|
113
|
+
c = (c << 14 | c >>> 18) + d | 0;
|
|
114
|
+
b += (c & a | d & ~a) + k[0] - 373897302 | 0;
|
|
115
|
+
b = (b << 20 | b >>> 12) + c | 0;
|
|
116
|
+
a += (b & d | c & ~d) + k[5] - 701558691 | 0;
|
|
117
|
+
a = (a << 5 | a >>> 27) + b | 0;
|
|
118
|
+
d += (a & c | b & ~c) + k[10] + 38016083 | 0;
|
|
119
|
+
d = (d << 9 | d >>> 23) + a | 0;
|
|
120
|
+
c += (d & b | a & ~b) + k[15] - 660478335 | 0;
|
|
121
|
+
c = (c << 14 | c >>> 18) + d | 0;
|
|
122
|
+
b += (c & a | d & ~a) + k[4] - 405537848 | 0;
|
|
123
|
+
b = (b << 20 | b >>> 12) + c | 0;
|
|
124
|
+
a += (b & d | c & ~d) + k[9] + 568446438 | 0;
|
|
125
|
+
a = (a << 5 | a >>> 27) + b | 0;
|
|
126
|
+
d += (a & c | b & ~c) + k[14] - 1019803690 | 0;
|
|
127
|
+
d = (d << 9 | d >>> 23) + a | 0;
|
|
128
|
+
c += (d & b | a & ~b) + k[3] - 187363961 | 0;
|
|
129
|
+
c = (c << 14 | c >>> 18) + d | 0;
|
|
130
|
+
b += (c & a | d & ~a) + k[8] + 1163531501 | 0;
|
|
131
|
+
b = (b << 20 | b >>> 12) + c | 0;
|
|
132
|
+
a += (b & d | c & ~d) + k[13] - 1444681467 | 0;
|
|
133
|
+
a = (a << 5 | a >>> 27) + b | 0;
|
|
134
|
+
d += (a & c | b & ~c) + k[2] - 51403784 | 0;
|
|
135
|
+
d = (d << 9 | d >>> 23) + a | 0;
|
|
136
|
+
c += (d & b | a & ~b) + k[7] + 1735328473 | 0;
|
|
137
|
+
c = (c << 14 | c >>> 18) + d | 0;
|
|
138
|
+
b += (c & a | d & ~a) + k[12] - 1926607734 | 0;
|
|
139
|
+
b = (b << 20 | b >>> 12) + c | 0;
|
|
140
|
+
a += (b ^ c ^ d) + k[5] - 378558 | 0;
|
|
141
|
+
a = (a << 4 | a >>> 28) + b | 0;
|
|
142
|
+
d += (a ^ b ^ c) + k[8] - 2022574463 | 0;
|
|
143
|
+
d = (d << 11 | d >>> 21) + a | 0;
|
|
144
|
+
c += (d ^ a ^ b) + k[11] + 1839030562 | 0;
|
|
145
|
+
c = (c << 16 | c >>> 16) + d | 0;
|
|
146
|
+
b += (c ^ d ^ a) + k[14] - 35309556 | 0;
|
|
147
|
+
b = (b << 23 | b >>> 9) + c | 0;
|
|
148
|
+
a += (b ^ c ^ d) + k[1] - 1530992060 | 0;
|
|
149
|
+
a = (a << 4 | a >>> 28) + b | 0;
|
|
150
|
+
d += (a ^ b ^ c) + k[4] + 1272893353 | 0;
|
|
151
|
+
d = (d << 11 | d >>> 21) + a | 0;
|
|
152
|
+
c += (d ^ a ^ b) + k[7] - 155497632 | 0;
|
|
153
|
+
c = (c << 16 | c >>> 16) + d | 0;
|
|
154
|
+
b += (c ^ d ^ a) + k[10] - 1094730640 | 0;
|
|
155
|
+
b = (b << 23 | b >>> 9) + c | 0;
|
|
156
|
+
a += (b ^ c ^ d) + k[13] + 681279174 | 0;
|
|
157
|
+
a = (a << 4 | a >>> 28) + b | 0;
|
|
158
|
+
d += (a ^ b ^ c) + k[0] - 358537222 | 0;
|
|
159
|
+
d = (d << 11 | d >>> 21) + a | 0;
|
|
160
|
+
c += (d ^ a ^ b) + k[3] - 722521979 | 0;
|
|
161
|
+
c = (c << 16 | c >>> 16) + d | 0;
|
|
162
|
+
b += (c ^ d ^ a) + k[6] + 76029189 | 0;
|
|
163
|
+
b = (b << 23 | b >>> 9) + c | 0;
|
|
164
|
+
a += (b ^ c ^ d) + k[9] - 640364487 | 0;
|
|
165
|
+
a = (a << 4 | a >>> 28) + b | 0;
|
|
166
|
+
d += (a ^ b ^ c) + k[12] - 421815835 | 0;
|
|
167
|
+
d = (d << 11 | d >>> 21) + a | 0;
|
|
168
|
+
c += (d ^ a ^ b) + k[15] + 530742520 | 0;
|
|
169
|
+
c = (c << 16 | c >>> 16) + d | 0;
|
|
170
|
+
b += (c ^ d ^ a) + k[2] - 995338651 | 0;
|
|
171
|
+
b = (b << 23 | b >>> 9) + c | 0;
|
|
172
|
+
a += (c ^ (b | ~d)) + k[0] - 198630844 | 0;
|
|
173
|
+
a = (a << 6 | a >>> 26) + b | 0;
|
|
174
|
+
d += (b ^ (a | ~c)) + k[7] + 1126891415 | 0;
|
|
175
|
+
d = (d << 10 | d >>> 22) + a | 0;
|
|
176
|
+
c += (a ^ (d | ~b)) + k[14] - 1416354905 | 0;
|
|
177
|
+
c = (c << 15 | c >>> 17) + d | 0;
|
|
178
|
+
b += (d ^ (c | ~a)) + k[5] - 57434055 | 0;
|
|
179
|
+
b = (b << 21 | b >>> 11) + c | 0;
|
|
180
|
+
a += (c ^ (b | ~d)) + k[12] + 1700485571 | 0;
|
|
181
|
+
a = (a << 6 | a >>> 26) + b | 0;
|
|
182
|
+
d += (b ^ (a | ~c)) + k[3] - 1894986606 | 0;
|
|
183
|
+
d = (d << 10 | d >>> 22) + a | 0;
|
|
184
|
+
c += (a ^ (d | ~b)) + k[10] - 1051523 | 0;
|
|
185
|
+
c = (c << 15 | c >>> 17) + d | 0;
|
|
186
|
+
b += (d ^ (c | ~a)) + k[1] - 2054922799 | 0;
|
|
187
|
+
b = (b << 21 | b >>> 11) + c | 0;
|
|
188
|
+
a += (c ^ (b | ~d)) + k[8] + 1873313359 | 0;
|
|
189
|
+
a = (a << 6 | a >>> 26) + b | 0;
|
|
190
|
+
d += (b ^ (a | ~c)) + k[15] - 30611744 | 0;
|
|
191
|
+
d = (d << 10 | d >>> 22) + a | 0;
|
|
192
|
+
c += (a ^ (d | ~b)) + k[6] - 1560198380 | 0;
|
|
193
|
+
c = (c << 15 | c >>> 17) + d | 0;
|
|
194
|
+
b += (d ^ (c | ~a)) + k[13] + 1309151649 | 0;
|
|
195
|
+
b = (b << 21 | b >>> 11) + c | 0;
|
|
196
|
+
a += (c ^ (b | ~d)) + k[4] - 145523070 | 0;
|
|
197
|
+
a = (a << 6 | a >>> 26) + b | 0;
|
|
198
|
+
d += (b ^ (a | ~c)) + k[11] - 1120210379 | 0;
|
|
199
|
+
d = (d << 10 | d >>> 22) + a | 0;
|
|
200
|
+
c += (a ^ (d | ~b)) + k[2] + 718787259 | 0;
|
|
201
|
+
c = (c << 15 | c >>> 17) + d | 0;
|
|
202
|
+
b += (d ^ (c | ~a)) + k[9] - 343485551 | 0;
|
|
203
|
+
b = (b << 21 | b >>> 11) + c | 0;
|
|
204
|
+
x[0] = a + x[0] | 0;
|
|
205
|
+
x[1] = b + x[1] | 0;
|
|
206
|
+
x[2] = c + x[2] | 0;
|
|
207
|
+
x[3] = d + x[3] | 0;
|
|
47
208
|
}
|
|
48
209
|
/**
|
|
49
210
|
* Initialise buffer to be hashed
|
|
50
211
|
*/
|
|
51
212
|
start() {
|
|
52
|
-
|
|
213
|
+
this._dataLength = 0;
|
|
214
|
+
this._bufferLength = 0;
|
|
215
|
+
this._state.set(_Md5.stateIdentity);
|
|
216
|
+
return this;
|
|
53
217
|
}
|
|
54
218
|
// Char to code point to to array conversion:
|
|
55
219
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt
|
|
@@ -58,136 +222,170 @@
|
|
|
58
222
|
* Append a UTF-8 string to the hash buffer
|
|
59
223
|
* @param str String to append
|
|
60
224
|
*/
|
|
61
|
-
appendStr(
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
else {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
225
|
+
appendStr(str) {
|
|
226
|
+
const buf8 = this._buffer8;
|
|
227
|
+
const buf32 = this._buffer32;
|
|
228
|
+
let bufLen = this._bufferLength;
|
|
229
|
+
let code;
|
|
230
|
+
let i;
|
|
231
|
+
for (i = 0; i < str.length; i += 1) {
|
|
232
|
+
code = str.charCodeAt(i);
|
|
233
|
+
if (code < 128) {
|
|
234
|
+
buf8[bufLen++] = code;
|
|
235
|
+
} else if (code < 2048) {
|
|
236
|
+
buf8[bufLen++] = (code >>> 6) + 192;
|
|
237
|
+
buf8[bufLen++] = code & 63 | 128;
|
|
238
|
+
} else if (code < 55296 || code > 56319) {
|
|
239
|
+
buf8[bufLen++] = (code >>> 12) + 224;
|
|
240
|
+
buf8[bufLen++] = code >>> 6 & 63 | 128;
|
|
241
|
+
buf8[bufLen++] = code & 63 | 128;
|
|
242
|
+
} else {
|
|
243
|
+
code = (code - 55296) * 1024 + (str.charCodeAt(++i) - 56320) + 65536;
|
|
244
|
+
if (code > 1114111) {
|
|
245
|
+
throw new Error("Unicode standard supports code points up to U+10FFFF");
|
|
246
|
+
}
|
|
247
|
+
buf8[bufLen++] = (code >>> 18) + 240;
|
|
248
|
+
buf8[bufLen++] = code >>> 12 & 63 | 128;
|
|
249
|
+
buf8[bufLen++] = code >>> 6 & 63 | 128;
|
|
250
|
+
buf8[bufLen++] = code & 63 | 128;
|
|
251
|
+
}
|
|
252
|
+
if (bufLen >= 64) {
|
|
253
|
+
this._dataLength += 64;
|
|
254
|
+
_Md5._md5cycle(this._state, buf32);
|
|
255
|
+
bufLen -= 64;
|
|
256
|
+
buf32[0] = buf32[16];
|
|
77
257
|
}
|
|
78
|
-
e >= 64 && (this._dataLength += 64, _h._md5cycle(this._state, t), e -= 64, t[0] = t[16]);
|
|
79
258
|
}
|
|
80
|
-
|
|
259
|
+
this._bufferLength = bufLen;
|
|
260
|
+
return this;
|
|
81
261
|
}
|
|
82
262
|
/**
|
|
83
263
|
* Append an ASCII string to the hash buffer
|
|
84
264
|
* @param str String to append
|
|
85
265
|
*/
|
|
86
|
-
appendAsciiStr(
|
|
87
|
-
const
|
|
88
|
-
|
|
266
|
+
appendAsciiStr(str) {
|
|
267
|
+
const buf8 = this._buffer8;
|
|
268
|
+
const buf32 = this._buffer32;
|
|
269
|
+
let bufLen = this._bufferLength;
|
|
270
|
+
let i;
|
|
271
|
+
let j = 0;
|
|
89
272
|
for (; ; ) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
273
|
+
i = Math.min(str.length - j, 64 - bufLen);
|
|
274
|
+
while (i--) {
|
|
275
|
+
buf8[bufLen++] = str.charCodeAt(j++);
|
|
276
|
+
}
|
|
277
|
+
if (bufLen < 64) {
|
|
93
278
|
break;
|
|
94
|
-
|
|
279
|
+
}
|
|
280
|
+
this._dataLength += 64;
|
|
281
|
+
_Md5._md5cycle(this._state, buf32);
|
|
282
|
+
bufLen = 0;
|
|
95
283
|
}
|
|
96
|
-
|
|
284
|
+
this._bufferLength = bufLen;
|
|
285
|
+
return this;
|
|
97
286
|
}
|
|
98
287
|
/**
|
|
99
288
|
* Append a byte array to the hash buffer
|
|
100
289
|
* @param input array to append
|
|
101
290
|
*/
|
|
102
|
-
appendByteArray(
|
|
103
|
-
const
|
|
104
|
-
|
|
291
|
+
appendByteArray(input) {
|
|
292
|
+
const buf8 = this._buffer8;
|
|
293
|
+
const buf32 = this._buffer32;
|
|
294
|
+
let bufLen = this._bufferLength;
|
|
295
|
+
let i;
|
|
296
|
+
let j = 0;
|
|
105
297
|
for (; ; ) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
298
|
+
i = Math.min(input.length - j, 64 - bufLen);
|
|
299
|
+
while (i--) {
|
|
300
|
+
buf8[bufLen++] = input[j++];
|
|
301
|
+
}
|
|
302
|
+
if (bufLen < 64) {
|
|
109
303
|
break;
|
|
110
|
-
|
|
304
|
+
}
|
|
305
|
+
this._dataLength += 64;
|
|
306
|
+
_Md5._md5cycle(this._state, buf32);
|
|
307
|
+
bufLen = 0;
|
|
111
308
|
}
|
|
112
|
-
|
|
309
|
+
this._bufferLength = bufLen;
|
|
310
|
+
return this;
|
|
113
311
|
}
|
|
114
312
|
/**
|
|
115
313
|
* Get the state of the hash buffer
|
|
116
314
|
*/
|
|
117
315
|
getState() {
|
|
118
|
-
const
|
|
316
|
+
const s = this._state;
|
|
119
317
|
return {
|
|
120
318
|
buffer: String.fromCharCode.apply(null, Array.from(this._buffer8)),
|
|
121
319
|
buflen: this._bufferLength,
|
|
122
320
|
length: this._dataLength,
|
|
123
|
-
state: [
|
|
321
|
+
state: [s[0], s[1], s[2], s[3]]
|
|
124
322
|
};
|
|
125
323
|
}
|
|
126
324
|
/**
|
|
127
325
|
* Override the current state of the hash buffer
|
|
128
326
|
* @param state New hash buffer state
|
|
129
327
|
*/
|
|
130
|
-
setState(
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
328
|
+
setState(state) {
|
|
329
|
+
const buf = state.buffer;
|
|
330
|
+
const x = state.state;
|
|
331
|
+
const s = this._state;
|
|
332
|
+
let i;
|
|
333
|
+
this._dataLength = state.length;
|
|
334
|
+
this._bufferLength = state.buflen;
|
|
335
|
+
s[0] = x[0];
|
|
336
|
+
s[1] = x[1];
|
|
337
|
+
s[2] = x[2];
|
|
338
|
+
s[3] = x[3];
|
|
339
|
+
for (i = 0; i < buf.length; i += 1) {
|
|
340
|
+
this._buffer8[i] = buf.charCodeAt(i);
|
|
341
|
+
}
|
|
135
342
|
}
|
|
136
343
|
/**
|
|
137
344
|
* Hash the current state of the hash buffer and return the result
|
|
138
345
|
* @param raw Whether to return the value as an `Int32Array`
|
|
139
346
|
*/
|
|
140
|
-
end(
|
|
141
|
-
const
|
|
142
|
-
this.
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
347
|
+
end(raw2 = false) {
|
|
348
|
+
const bufLen = this._bufferLength;
|
|
349
|
+
const buf8 = this._buffer8;
|
|
350
|
+
const buf32 = this._buffer32;
|
|
351
|
+
const i = (bufLen >> 2) + 1;
|
|
352
|
+
this._dataLength += bufLen;
|
|
353
|
+
const dataBitsLen = this._dataLength * 8;
|
|
354
|
+
buf8[bufLen] = 128;
|
|
355
|
+
buf8[bufLen + 1] = buf8[bufLen + 2] = buf8[bufLen + 3] = 0;
|
|
356
|
+
buf32.set(_Md5.buffer32Identity.subarray(i), i);
|
|
357
|
+
if (bufLen > 55) {
|
|
358
|
+
_Md5._md5cycle(this._state, buf32);
|
|
359
|
+
buf32.set(_Md5.buffer32Identity);
|
|
360
|
+
}
|
|
361
|
+
if (dataBitsLen <= 4294967295) {
|
|
362
|
+
buf32[14] = dataBitsLen;
|
|
363
|
+
} else {
|
|
364
|
+
const matches = dataBitsLen.toString(16).match(/(.*?)(.{0,8})$/);
|
|
365
|
+
if (matches === null) {
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
const lo = parseInt(matches[2], 16);
|
|
369
|
+
const hi = parseInt(matches[1], 16) || 0;
|
|
370
|
+
buf32[14] = lo;
|
|
371
|
+
buf32[15] = hi;
|
|
151
372
|
}
|
|
152
|
-
|
|
373
|
+
_Md5._md5cycle(this._state, buf32);
|
|
374
|
+
return raw2 ? this._state : _Md5._hex(this._state);
|
|
153
375
|
}
|
|
154
376
|
};
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
]));
|
|
162
|
-
__publicField(_h, "buffer32Identity", new Int32Array([
|
|
163
|
-
0,
|
|
164
|
-
0,
|
|
165
|
-
0,
|
|
166
|
-
0,
|
|
167
|
-
0,
|
|
168
|
-
0,
|
|
169
|
-
0,
|
|
170
|
-
0,
|
|
171
|
-
0,
|
|
172
|
-
0,
|
|
173
|
-
0,
|
|
174
|
-
0,
|
|
175
|
-
0,
|
|
176
|
-
0,
|
|
177
|
-
0,
|
|
178
|
-
0
|
|
179
|
-
]));
|
|
180
|
-
__publicField(_h, "hexChars", "0123456789abcdef");
|
|
181
|
-
__publicField(_h, "hexOut", []);
|
|
182
|
-
// Permanent instance is to use for one-call hashing
|
|
183
|
-
__publicField(_h, "onePassHasher", new _h());
|
|
184
|
-
var h = _h;
|
|
185
|
-
if (h.hashStr("hello") !== "5d41402abc4b2a76b9719d911017c592")
|
|
377
|
+
Md5.stateIdentity = new Int32Array([1732584193, -271733879, -1732584194, 271733878]);
|
|
378
|
+
Md5.buffer32Identity = new Int32Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
|
379
|
+
Md5.hexChars = "0123456789abcdef";
|
|
380
|
+
Md5.hexOut = [];
|
|
381
|
+
Md5.onePassHasher = new Md5();
|
|
382
|
+
if (Md5.hashStr("hello") !== "5d41402abc4b2a76b9719d911017c592") {
|
|
186
383
|
throw new Error("Md5 self test failed.");
|
|
384
|
+
}
|
|
187
385
|
|
|
188
386
|
// src/util/sign.ts
|
|
189
387
|
function md5(str) {
|
|
190
|
-
return
|
|
388
|
+
return Md5.hashStr(str);
|
|
191
389
|
}
|
|
192
390
|
function raw(args) {
|
|
193
391
|
let keys = Object.keys(args);
|
|
@@ -216,7 +414,9 @@
|
|
|
216
414
|
}
|
|
217
415
|
|
|
218
416
|
// src/index.ts
|
|
219
|
-
var
|
|
417
|
+
var qjutil = {
|
|
220
418
|
sign: sign_exports
|
|
221
419
|
};
|
|
420
|
+
var index_default = qjutil;
|
|
421
|
+
return __toCommonJS(index_exports);
|
|
222
422
|
})();
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qjutil",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.8",
|
|
4
|
+
"main": "dist/index.cjs.js",
|
|
5
|
+
"browser": "dist/index.iife.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist"
|
|
9
|
-
],
|
|
7
|
+
"files": ["dist"],
|
|
10
8
|
"scripts": {
|
|
11
|
-
"build": "tsup src/index.ts --format
|
|
12
|
-
"gptBuild": "tsup src/index.ts --format cjs,esm,iife --global-name qjutil --dts --out-dir dist",
|
|
9
|
+
"build": "tsup src/index.ts --format cjs,iife --global-name qjutil --dts --out-dir dist",
|
|
13
10
|
"prepublishOnly": "npm run build"
|
|
14
11
|
},
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"ts-md5": "^1.2.7"
|
|
14
|
+
},
|
|
18
15
|
"devDependencies": {
|
|
19
|
-
"@types/node": "^25.0.3",
|
|
20
16
|
"tsup": "^8.5.1",
|
|
21
|
-
"typescript": "^5.9.3"
|
|
22
|
-
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"ts-md5": "^2.0.1"
|
|
17
|
+
"typescript": "^5.9.3",
|
|
18
|
+
"@types/node": "^25.0.3"
|
|
25
19
|
}
|
|
26
|
-
}
|
|
20
|
+
}
|