ddan-js 2.7.10 → 2.8.0
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/bin/ddan-js.esm.js +1 -1
- package/bin/ddan-js.js +1 -1
- package/bin/lib/modules/convert/base.js +112 -0
- package/bin/lib/modules/convert/index.js +4 -47
- package/bin/lib/modules/convert/pkcs.js +16 -0
- package/bin/lib/modules/crypto/index.js +2 -0
- package/bin/lib/modules/crypto/tea.js +78 -0
- package/bin/types/index.d.ts +66 -15
- package/bin/types/modules/convert/base.d.ts +14 -0
- package/bin/types/modules/convert/index.d.ts +13 -5
- package/bin/types/modules/convert/pkcs.d.ts +5 -0
- package/bin/types/modules/crypto/index.d.ts +9 -0
- package/bin/types/modules/crypto/tea.d.ts +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const is_1 = require("../../util/is");
|
|
4
|
+
const bytes2str = (bytes) => {
|
|
5
|
+
if (!bytes || !is_1.default.isArrayLike(bytes))
|
|
6
|
+
return '';
|
|
7
|
+
const str = bytes.reduce((str, byte) => str + String.fromCharCode(byte), '');
|
|
8
|
+
return str;
|
|
9
|
+
};
|
|
10
|
+
const str2bytes = (str = '') => {
|
|
11
|
+
const content = str;
|
|
12
|
+
const bufView = new Uint8Array(content.length);
|
|
13
|
+
for (let i = 0, strLen = content.length; i < strLen; i++) {
|
|
14
|
+
bufView[i] = content.charCodeAt(i);
|
|
15
|
+
}
|
|
16
|
+
return bufView;
|
|
17
|
+
};
|
|
18
|
+
const str2hex = (str) => {
|
|
19
|
+
let hexString = '';
|
|
20
|
+
for (let i = 0; i < str.length; i++) {
|
|
21
|
+
hexString += str.charCodeAt(i).toString(16).padStart(2, '0');
|
|
22
|
+
}
|
|
23
|
+
return hexString;
|
|
24
|
+
};
|
|
25
|
+
const hex2str = (hexstr) => {
|
|
26
|
+
let str = '';
|
|
27
|
+
for (let i = 0; i < hexstr.length; i += 2) {
|
|
28
|
+
str += String.fromCharCode(parseInt(hexstr.substr(i, 2), 16));
|
|
29
|
+
}
|
|
30
|
+
return str;
|
|
31
|
+
};
|
|
32
|
+
const concatBytes = (...args) => {
|
|
33
|
+
// 计算所有 Uint8Array 的总长度
|
|
34
|
+
const totalLength = args.reduce((sum, arr) => sum + arr.length, 0);
|
|
35
|
+
// 创建一个新的 Uint8Array
|
|
36
|
+
const combined = new Uint8Array(totalLength);
|
|
37
|
+
// 当前写入的位置
|
|
38
|
+
let offset = 0;
|
|
39
|
+
// 将每个 Uint8Array 复制到新的数组中
|
|
40
|
+
for (const arr of args) {
|
|
41
|
+
combined.set(arr, offset);
|
|
42
|
+
offset += arr.length;
|
|
43
|
+
}
|
|
44
|
+
return combined;
|
|
45
|
+
};
|
|
46
|
+
const uint32ToBytes = (uint32) => {
|
|
47
|
+
const bytes = new Uint8Array(8);
|
|
48
|
+
bytes[0] = (uint32[0] >>> 24) & 0xff;
|
|
49
|
+
bytes[1] = (uint32[0] >>> 16) & 0xff;
|
|
50
|
+
bytes[2] = (uint32[0] >>> 8) & 0xff;
|
|
51
|
+
bytes[3] = uint32[0] & 0xff;
|
|
52
|
+
bytes[4] = (uint32[1] >>> 24) & 0xff;
|
|
53
|
+
bytes[5] = (uint32[1] >>> 16) & 0xff;
|
|
54
|
+
bytes[6] = (uint32[1] >>> 8) & 0xff;
|
|
55
|
+
bytes[7] = uint32[1] & 0xff;
|
|
56
|
+
return bytes;
|
|
57
|
+
};
|
|
58
|
+
const bytesToUint32 = (bytes) => {
|
|
59
|
+
const unit32 = new Uint32Array(2);
|
|
60
|
+
unit32[0] = (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3];
|
|
61
|
+
unit32[1] = (bytes[4] << 24) | (bytes[5] << 16) | (bytes[6] << 8) | bytes[7];
|
|
62
|
+
return unit32;
|
|
63
|
+
};
|
|
64
|
+
const toUint32 = (str) => {
|
|
65
|
+
const length = Math.ceil(str.length / 4);
|
|
66
|
+
const uint32Array = new Uint32Array(length);
|
|
67
|
+
for (let i = 0; i < length; i++) {
|
|
68
|
+
uint32Array[i] =
|
|
69
|
+
(str.charCodeAt(i * 4) << 24) |
|
|
70
|
+
(str.charCodeAt(i * 4 + 1) << 16) |
|
|
71
|
+
(str.charCodeAt(i * 4 + 2) << 8) |
|
|
72
|
+
str.charCodeAt(i * 4 + 3);
|
|
73
|
+
}
|
|
74
|
+
return uint32Array;
|
|
75
|
+
};
|
|
76
|
+
const fromUint32 = (uint32) => {
|
|
77
|
+
let result = '';
|
|
78
|
+
for (let i = 0; i < uint32.length; i++) {
|
|
79
|
+
result += String.fromCharCode((uint32[i] >>> 24) & 0xff, // 提取最高 8 位
|
|
80
|
+
(uint32[i] >>> 16) & 0xff, // 提取次高 8 位
|
|
81
|
+
(uint32[i] >>> 8) & 0xff, // 提取次低 8 位
|
|
82
|
+
uint32[i] & 0xff // 提取最低 8 位
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
// 去掉可能因字符串长度不是4的倍数导致的填充字符
|
|
86
|
+
return result.replace(/\0+$/, '');
|
|
87
|
+
};
|
|
88
|
+
const hex2bytes = (hex) => {
|
|
89
|
+
let bytes = new Uint8Array(hex.length / 2);
|
|
90
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
91
|
+
bytes[i] = parseInt(hex.substr(i * 2, 2), 16);
|
|
92
|
+
}
|
|
93
|
+
return bytes;
|
|
94
|
+
};
|
|
95
|
+
const bytes2hex = (bytes) => {
|
|
96
|
+
return Array.from(bytes)
|
|
97
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
98
|
+
.join('');
|
|
99
|
+
};
|
|
100
|
+
exports.default = {
|
|
101
|
+
bytes2str,
|
|
102
|
+
str2bytes,
|
|
103
|
+
str2hex,
|
|
104
|
+
hex2str,
|
|
105
|
+
concatBytes,
|
|
106
|
+
uint32ToBytes,
|
|
107
|
+
bytesToUint32,
|
|
108
|
+
hex2bytes,
|
|
109
|
+
bytes2hex,
|
|
110
|
+
toUint32,
|
|
111
|
+
fromUint32,
|
|
112
|
+
};
|
|
@@ -4,6 +4,8 @@ const base64_1 = require("./base64");
|
|
|
4
4
|
const is_1 = require("../../util/is");
|
|
5
5
|
const utf8_1 = require("./utf8");
|
|
6
6
|
const math_1 = require("../math");
|
|
7
|
+
const base_1 = require("./base");
|
|
8
|
+
const pkcs_1 = require("./pkcs");
|
|
7
9
|
const str2ab = (content = '', base64 = false) => {
|
|
8
10
|
if (base64) {
|
|
9
11
|
return base64_1.default.base64ToBytes(content).buffer;
|
|
@@ -26,34 +28,6 @@ const ab2str = (data, base64 = false) => {
|
|
|
26
28
|
return uint8Array.reduce((str, byte) => str + String.fromCharCode(byte), '');
|
|
27
29
|
}
|
|
28
30
|
};
|
|
29
|
-
const bytesToStr = (bytes) => {
|
|
30
|
-
if (!bytes || !is_1.default.isArrayLike(bytes))
|
|
31
|
-
return '';
|
|
32
|
-
const str = bytes.reduce((str, byte) => str + String.fromCharCode(byte), '');
|
|
33
|
-
return str;
|
|
34
|
-
};
|
|
35
|
-
const strToBytes = (str = '') => {
|
|
36
|
-
const content = str;
|
|
37
|
-
const bufView = new Uint8Array(content.length);
|
|
38
|
-
for (let i = 0, strLen = content.length; i < strLen; i++) {
|
|
39
|
-
bufView[i] = content.charCodeAt(i);
|
|
40
|
-
}
|
|
41
|
-
return bufView;
|
|
42
|
-
};
|
|
43
|
-
const str2Hex = (str) => {
|
|
44
|
-
let hexString = '';
|
|
45
|
-
for (let i = 0; i < str.length; i++) {
|
|
46
|
-
hexString += str.charCodeAt(i).toString(16).padStart(2, '0');
|
|
47
|
-
}
|
|
48
|
-
return hexString;
|
|
49
|
-
};
|
|
50
|
-
const hex2Str = (hexstr) => {
|
|
51
|
-
let str = '';
|
|
52
|
-
for (let i = 0; i < hexstr.length; i += 2) {
|
|
53
|
-
str += String.fromCharCode(parseInt(hexstr.substr(i, 2), 16));
|
|
54
|
-
}
|
|
55
|
-
return str;
|
|
56
|
-
};
|
|
57
31
|
const utf8ToBase64 = (str) => {
|
|
58
32
|
if (is_1.default.isBrowser) {
|
|
59
33
|
return btoa(str);
|
|
@@ -107,34 +81,17 @@ const toDataUrl = (textOrBuf, contentType = 'text/plain') => {
|
|
|
107
81
|
}
|
|
108
82
|
return '';
|
|
109
83
|
};
|
|
110
|
-
const concatBytes = (...args) => {
|
|
111
|
-
// 计算所有 Uint8Array 的总长度
|
|
112
|
-
const totalLength = args.reduce((sum, arr) => sum + arr.length, 0);
|
|
113
|
-
// 创建一个新的 Uint8Array
|
|
114
|
-
const combined = new Uint8Array(totalLength);
|
|
115
|
-
// 当前写入的位置
|
|
116
|
-
let offset = 0;
|
|
117
|
-
// 将每个 Uint8Array 复制到新的数组中
|
|
118
|
-
for (const arr of args) {
|
|
119
|
-
combined.set(arr, offset);
|
|
120
|
-
offset += arr.length;
|
|
121
|
-
}
|
|
122
|
-
return combined;
|
|
123
|
-
};
|
|
124
84
|
exports.default = {
|
|
85
|
+
...base_1.default,
|
|
86
|
+
...pkcs_1.default,
|
|
125
87
|
...utf8_1.default,
|
|
126
88
|
...base64_1.default,
|
|
127
|
-
str2Hex,
|
|
128
|
-
hex2Str,
|
|
129
89
|
str2ab,
|
|
130
90
|
ab2str,
|
|
131
|
-
bytesToStr,
|
|
132
|
-
strToBytes,
|
|
133
91
|
utf8ToBase64,
|
|
134
92
|
base64ToUtf8,
|
|
135
93
|
getRandomBytes,
|
|
136
94
|
textEncode,
|
|
137
95
|
textDecode,
|
|
138
96
|
toDataUrl,
|
|
139
|
-
concatBytes,
|
|
140
97
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const base_1 = require("./base");
|
|
4
|
+
// PKCS#7 填充函数,将明文填充到指定的块大小(8 字节)
|
|
5
|
+
const pkcs7Padding = (plaintext, blockSize) => {
|
|
6
|
+
const padding = blockSize - (plaintext.length % blockSize);
|
|
7
|
+
const padtext = new Uint8Array(padding).fill(padding);
|
|
8
|
+
const result = base_1.default.concatBytes(plaintext, padtext);
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
// PKCS#7 去除填充函数,解密后去掉填充字符
|
|
12
|
+
const pkcs7Unpadding = (ciphertext) => {
|
|
13
|
+
const padding = ciphertext[ciphertext.length - 1];
|
|
14
|
+
return ciphertext.slice(0, -padding);
|
|
15
|
+
};
|
|
16
|
+
exports.default = { pkcs7Padding, pkcs7Unpadding };
|
|
@@ -4,6 +4,7 @@ const time_1 = require("../time");
|
|
|
4
4
|
const base64_1 = require("./base64");
|
|
5
5
|
const const_1 = require("./const");
|
|
6
6
|
const uuid_1 = require("./uuid");
|
|
7
|
+
const tea_1 = require("./tea");
|
|
7
8
|
const guid = (len, prefix = false, sep = "") => {
|
|
8
9
|
const pwd = (0, uuid_1.default)(len || 32);
|
|
9
10
|
if (!prefix)
|
|
@@ -22,6 +23,7 @@ const getHexString = (len) => {
|
|
|
22
23
|
exports.default = {
|
|
23
24
|
...const_1.default,
|
|
24
25
|
base64: base64_1.default,
|
|
26
|
+
tea: tea_1.default,
|
|
25
27
|
uuid: uuid_1.default,
|
|
26
28
|
guid,
|
|
27
29
|
getHexString
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const convert_1 = require("../convert");
|
|
4
|
+
const delta = 0x9e3779b9; // 常量 Delta
|
|
5
|
+
const encrypt = (v, teaKey) => {
|
|
6
|
+
let sum = 0;
|
|
7
|
+
const n = 32; // 32轮加密
|
|
8
|
+
for (let i = 0; i < n; i++) {
|
|
9
|
+
sum = (sum + delta) >>> 0;
|
|
10
|
+
v[0] = (v[0] + (((v[1] << 4) + teaKey[0]) ^ (v[1] + sum) ^ ((v[1] >>> 5) + teaKey[1]))) >>> 0;
|
|
11
|
+
v[1] = (v[1] + (((v[0] << 4) + teaKey[2]) ^ (v[0] + sum) ^ ((v[0] >>> 5) + teaKey[3]))) >>> 0;
|
|
12
|
+
}
|
|
13
|
+
return v;
|
|
14
|
+
};
|
|
15
|
+
const decrypt = (v, teaKey) => {
|
|
16
|
+
const n = 32; // 32轮解密
|
|
17
|
+
let sum = (delta * n) >>> 0;
|
|
18
|
+
for (let i = 0; i < n; i++) {
|
|
19
|
+
v[1] = (v[1] - (((v[0] << 4) + teaKey[2]) ^ (v[0] + sum) ^ ((v[0] >>> 5) + teaKey[3]))) >>> 0;
|
|
20
|
+
v[0] = (v[0] - (((v[1] << 4) + teaKey[0]) ^ (v[1] + sum) ^ ((v[1] >>> 5) + teaKey[1]))) >>> 0;
|
|
21
|
+
sum = (sum - delta) >>> 0;
|
|
22
|
+
}
|
|
23
|
+
return v;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* TEA KEY
|
|
27
|
+
* @param str 位
|
|
28
|
+
* @returns 4组32位
|
|
29
|
+
*/
|
|
30
|
+
const toTeaKey = (str) => {
|
|
31
|
+
const keyBytes = convert_1.default.str2bytes(str);
|
|
32
|
+
const key = new Uint32Array(4);
|
|
33
|
+
key[0] = (keyBytes[0] << 24) | (keyBytes[1] << 16) | (keyBytes[2] << 8) | keyBytes[3];
|
|
34
|
+
key[1] = (keyBytes[4] << 24) | (keyBytes[5] << 16) | (keyBytes[6] << 8) | keyBytes[7];
|
|
35
|
+
key[2] = (keyBytes[8] << 24) | (keyBytes[9] << 16) | (keyBytes[10] << 8) | keyBytes[11];
|
|
36
|
+
key[3] = (keyBytes[12] << 24) | (keyBytes[13] << 16) | (keyBytes[14] << 8) | keyBytes[15];
|
|
37
|
+
return key;
|
|
38
|
+
};
|
|
39
|
+
const encodeBytes = (plainbytes, key) => {
|
|
40
|
+
// 转换明文为字节数组并进行PKCS#7填充
|
|
41
|
+
const padded = convert_1.default.pkcs7Padding(plainbytes, 8);
|
|
42
|
+
// 将明文分块并加密
|
|
43
|
+
const key4LongBytes = toTeaKey(key);
|
|
44
|
+
const encryptedBlocks = [];
|
|
45
|
+
for (let i = 0; i < padded.length; i += 8) {
|
|
46
|
+
const block = convert_1.default.bytesToUint32(padded.slice(i, i + 8));
|
|
47
|
+
const encryptedBlock = encrypt(block, key4LongBytes);
|
|
48
|
+
encryptedBlocks.push(convert_1.default.uint32ToBytes(encryptedBlock));
|
|
49
|
+
}
|
|
50
|
+
const encoded = convert_1.default.concatBytes(...encryptedBlocks);
|
|
51
|
+
return encoded;
|
|
52
|
+
};
|
|
53
|
+
const decodeBytes = (cipherbytes, key) => {
|
|
54
|
+
// 将密文分块并解密
|
|
55
|
+
const key4LongBytes = toTeaKey(key);
|
|
56
|
+
const decryptedBlocks = [];
|
|
57
|
+
for (let i = 0; i < cipherbytes.length; i += 8) {
|
|
58
|
+
const block = convert_1.default.bytesToUint32(cipherbytes.slice(i, i + 8));
|
|
59
|
+
const decryptedBlock = decrypt(block, key4LongBytes);
|
|
60
|
+
decryptedBlocks.push(convert_1.default.uint32ToBytes(decryptedBlock));
|
|
61
|
+
}
|
|
62
|
+
const decryptedBytes = convert_1.default.concatBytes(...decryptedBlocks);
|
|
63
|
+
// 去除填充并返回明文
|
|
64
|
+
const decryptedUnpaddBytes = convert_1.default.pkcs7Unpadding(decryptedBytes);
|
|
65
|
+
return decryptedUnpaddBytes;
|
|
66
|
+
};
|
|
67
|
+
const encode = (plaintext, key) => {
|
|
68
|
+
// 转换明文为字节数组并进行PKCS#7填充
|
|
69
|
+
const plainBytes = convert_1.default.textEncode(plaintext);
|
|
70
|
+
const encoded = encodeBytes(plainBytes, key);
|
|
71
|
+
return convert_1.default.bytesToBase64(encoded);
|
|
72
|
+
};
|
|
73
|
+
const decode = (ciphertext, key) => {
|
|
74
|
+
const cipherBytes = convert_1.default.base64ToBytes(ciphertext);
|
|
75
|
+
const decryptedBytes = decodeBytes(cipherBytes, key);
|
|
76
|
+
return convert_1.default.textDecode(decryptedBytes.buffer);
|
|
77
|
+
};
|
|
78
|
+
exports.default = { encrypt, decrypt, toTeaKey, encode, decode, encodeBytes, decodeBytes };
|
package/bin/types/index.d.ts
CHANGED
|
@@ -63,6 +63,15 @@ declare const dUtil: {
|
|
|
63
63
|
decode: (base64Str: string) => string;
|
|
64
64
|
encodeByOss: (input: string) => string;
|
|
65
65
|
};
|
|
66
|
+
tea: {
|
|
67
|
+
encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
68
|
+
decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
69
|
+
toTeaKey: (str: string) => Uint32Array;
|
|
70
|
+
encode: (plaintext: string, key: string) => string;
|
|
71
|
+
decode: (ciphertext: string, key: string) => string;
|
|
72
|
+
encodeBytes: (plainbytes: Uint8Array, key: string) => Uint8Array;
|
|
73
|
+
decodeBytes: (cipherbytes: Uint8Array, key: string) => Uint8Array;
|
|
74
|
+
};
|
|
66
75
|
uuid: (len?: number, radix?: number) => string;
|
|
67
76
|
guid: (len: number, prefix?: boolean, sep?: string) => string;
|
|
68
77
|
getHexString: (len: number) => string;
|
|
@@ -70,19 +79,14 @@ declare const dUtil: {
|
|
|
70
79
|
keyLower: string;
|
|
71
80
|
keyUpper: string;
|
|
72
81
|
keyChars: string;
|
|
73
|
-
str2Hex: (str: string) => string;
|
|
74
|
-
hex2Str: (hexstr: string) => string;
|
|
75
82
|
str2ab: (content?: string, base64?: boolean) => ArrayBuffer;
|
|
76
83
|
ab2str: (data: ArrayBuffer, base64?: boolean) => string;
|
|
77
|
-
bytesToStr: (bytes: Uint8Array) => string;
|
|
78
|
-
strToBytes: (str?: string) => Uint8Array;
|
|
79
84
|
utf8ToBase64: (str: string) => string;
|
|
80
85
|
base64ToUtf8: (base64Str: string) => string;
|
|
81
86
|
getRandomBytes: (length: number) => Uint8Array;
|
|
82
87
|
textEncode: (text: string) => Uint8Array;
|
|
83
88
|
textDecode: (buf: ArrayBufferLike) => string;
|
|
84
89
|
toDataUrl: (textOrBuf: string | ArrayBuffer, contentType?: string) => string;
|
|
85
|
-
concatBytes: (...args: Uint8Array[]) => Uint8Array;
|
|
86
90
|
toBase64: (input?: string) => string;
|
|
87
91
|
fromBase64: (input?: string) => string;
|
|
88
92
|
bytesToBase64: (bytes: Uint8Array) => string;
|
|
@@ -91,6 +95,19 @@ declare const dUtil: {
|
|
|
91
95
|
fromUtf8: (utftext: string) => string;
|
|
92
96
|
toUtf8Bytes: (content: string) => Uint8Array;
|
|
93
97
|
fromUtf8Bytes: (utf8Bytes: Uint8Array) => string;
|
|
98
|
+
pkcs7Padding: (plaintext: Uint8Array, blockSize: number) => Uint8Array;
|
|
99
|
+
pkcs7Unpadding: (ciphertext: Uint8Array) => Uint8Array;
|
|
100
|
+
bytes2str: (bytes: Uint8Array) => string;
|
|
101
|
+
str2bytes: (str?: string) => Uint8Array;
|
|
102
|
+
str2hex: (str: string) => string;
|
|
103
|
+
hex2str: (hexstr: string) => string;
|
|
104
|
+
concatBytes: (...args: Uint8Array[]) => Uint8Array;
|
|
105
|
+
uint32ToBytes: (uint32: Uint32Array) => Uint8Array;
|
|
106
|
+
bytesToUint32: (bytes: Uint8Array) => Uint32Array;
|
|
107
|
+
hex2bytes: (hex: string) => Uint8Array;
|
|
108
|
+
bytes2hex: (bytes: Uint8Array) => string;
|
|
109
|
+
toUint32: (str: string) => Uint32Array;
|
|
110
|
+
fromUint32: (uint32: Uint32Array) => string;
|
|
94
111
|
gbk: {
|
|
95
112
|
gbkLength: (str: string) => number;
|
|
96
113
|
gbkCut: (source: string, len: number) => string;
|
|
@@ -306,6 +323,15 @@ declare const dHook: {
|
|
|
306
323
|
decode: (base64Str: string) => string;
|
|
307
324
|
encodeByOss: (input: string) => string;
|
|
308
325
|
};
|
|
326
|
+
tea: {
|
|
327
|
+
encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
328
|
+
decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
329
|
+
toTeaKey: (str: string) => Uint32Array;
|
|
330
|
+
encode: (plaintext: string, key: string) => string;
|
|
331
|
+
decode: (ciphertext: string, key: string) => string;
|
|
332
|
+
encodeBytes: (plainbytes: Uint8Array, key: string) => Uint8Array;
|
|
333
|
+
decodeBytes: (cipherbytes: Uint8Array, key: string) => Uint8Array;
|
|
334
|
+
};
|
|
309
335
|
uuid: (len?: number, radix?: number) => string;
|
|
310
336
|
guid: (len: number, prefix?: boolean, sep?: string) => string;
|
|
311
337
|
getHexString: (len: number) => string;
|
|
@@ -313,19 +339,14 @@ declare const dHook: {
|
|
|
313
339
|
keyLower: string;
|
|
314
340
|
keyUpper: string;
|
|
315
341
|
keyChars: string;
|
|
316
|
-
str2Hex: (str: string) => string;
|
|
317
|
-
hex2Str: (hexstr: string) => string;
|
|
318
342
|
str2ab: (content?: string, base64?: boolean) => ArrayBuffer;
|
|
319
343
|
ab2str: (data: ArrayBuffer, base64?: boolean) => string;
|
|
320
|
-
bytesToStr: (bytes: Uint8Array) => string;
|
|
321
|
-
strToBytes: (str?: string) => Uint8Array;
|
|
322
344
|
utf8ToBase64: (str: string) => string;
|
|
323
345
|
base64ToUtf8: (base64Str: string) => string;
|
|
324
346
|
getRandomBytes: (length: number) => Uint8Array;
|
|
325
347
|
textEncode: (text: string) => Uint8Array;
|
|
326
348
|
textDecode: (buf: ArrayBufferLike) => string;
|
|
327
349
|
toDataUrl: (textOrBuf: string | ArrayBuffer, contentType?: string) => string;
|
|
328
|
-
concatBytes: (...args: Uint8Array[]) => Uint8Array;
|
|
329
350
|
toBase64: (input?: string) => string;
|
|
330
351
|
fromBase64: (input?: string) => string;
|
|
331
352
|
bytesToBase64: (bytes: Uint8Array) => string;
|
|
@@ -334,6 +355,19 @@ declare const dHook: {
|
|
|
334
355
|
fromUtf8: (utftext: string) => string;
|
|
335
356
|
toUtf8Bytes: (content: string) => Uint8Array;
|
|
336
357
|
fromUtf8Bytes: (utf8Bytes: Uint8Array) => string;
|
|
358
|
+
pkcs7Padding: (plaintext: Uint8Array, blockSize: number) => Uint8Array;
|
|
359
|
+
pkcs7Unpadding: (ciphertext: Uint8Array) => Uint8Array;
|
|
360
|
+
bytes2str: (bytes: Uint8Array) => string;
|
|
361
|
+
str2bytes: (str?: string) => Uint8Array;
|
|
362
|
+
str2hex: (str: string) => string;
|
|
363
|
+
hex2str: (hexstr: string) => string;
|
|
364
|
+
concatBytes: (...args: Uint8Array[]) => Uint8Array;
|
|
365
|
+
uint32ToBytes: (uint32: Uint32Array) => Uint8Array;
|
|
366
|
+
bytesToUint32: (bytes: Uint8Array) => Uint32Array;
|
|
367
|
+
hex2bytes: (hex: string) => Uint8Array;
|
|
368
|
+
bytes2hex: (bytes: Uint8Array) => string;
|
|
369
|
+
toUint32: (str: string) => Uint32Array;
|
|
370
|
+
fromUint32: (uint32: Uint32Array) => string;
|
|
337
371
|
};
|
|
338
372
|
declare const dMini: {
|
|
339
373
|
mini: {
|
|
@@ -792,6 +826,15 @@ declare const _default: {
|
|
|
792
826
|
decode: (base64Str: string) => string;
|
|
793
827
|
encodeByOss: (input: string) => string;
|
|
794
828
|
};
|
|
829
|
+
tea: {
|
|
830
|
+
encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
831
|
+
decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
832
|
+
toTeaKey: (str: string) => Uint32Array;
|
|
833
|
+
encode: (plaintext: string, key: string) => string;
|
|
834
|
+
decode: (ciphertext: string, key: string) => string;
|
|
835
|
+
encodeBytes: (plainbytes: Uint8Array, key: string) => Uint8Array;
|
|
836
|
+
decodeBytes: (cipherbytes: Uint8Array, key: string) => Uint8Array;
|
|
837
|
+
};
|
|
795
838
|
uuid: (len?: number, radix?: number) => string;
|
|
796
839
|
guid: (len: number, prefix?: boolean, sep?: string) => string;
|
|
797
840
|
getHexString: (len: number) => string;
|
|
@@ -934,19 +977,14 @@ declare const _default: {
|
|
|
934
977
|
};
|
|
935
978
|
};
|
|
936
979
|
convert: {
|
|
937
|
-
str2Hex: (str: string) => string;
|
|
938
|
-
hex2Str: (hexstr: string) => string;
|
|
939
980
|
str2ab: (content?: string, base64?: boolean) => ArrayBuffer;
|
|
940
981
|
ab2str: (data: ArrayBuffer, base64?: boolean) => string;
|
|
941
|
-
bytesToStr: (bytes: Uint8Array) => string;
|
|
942
|
-
strToBytes: (str?: string) => Uint8Array;
|
|
943
982
|
utf8ToBase64: (str: string) => string;
|
|
944
983
|
base64ToUtf8: (base64Str: string) => string;
|
|
945
984
|
getRandomBytes: (length: number) => Uint8Array;
|
|
946
985
|
textEncode: (text: string) => Uint8Array;
|
|
947
986
|
textDecode: (buf: ArrayBufferLike) => string;
|
|
948
987
|
toDataUrl: (textOrBuf: string | ArrayBuffer, contentType?: string) => string;
|
|
949
|
-
concatBytes: (...args: Uint8Array[]) => Uint8Array;
|
|
950
988
|
toBase64: (input?: string) => string;
|
|
951
989
|
fromBase64: (input?: string) => string;
|
|
952
990
|
bytesToBase64: (bytes: Uint8Array) => string;
|
|
@@ -955,6 +993,19 @@ declare const _default: {
|
|
|
955
993
|
fromUtf8: (utftext: string) => string;
|
|
956
994
|
toUtf8Bytes: (content: string) => Uint8Array;
|
|
957
995
|
fromUtf8Bytes: (utf8Bytes: Uint8Array) => string;
|
|
996
|
+
pkcs7Padding: (plaintext: Uint8Array, blockSize: number) => Uint8Array;
|
|
997
|
+
pkcs7Unpadding: (ciphertext: Uint8Array) => Uint8Array;
|
|
998
|
+
bytes2str: (bytes: Uint8Array) => string;
|
|
999
|
+
str2bytes: (str?: string) => Uint8Array;
|
|
1000
|
+
str2hex: (str: string) => string;
|
|
1001
|
+
hex2str: (hexstr: string) => string;
|
|
1002
|
+
concatBytes: (...args: Uint8Array[]) => Uint8Array;
|
|
1003
|
+
uint32ToBytes: (uint32: Uint32Array) => Uint8Array;
|
|
1004
|
+
bytesToUint32: (bytes: Uint8Array) => Uint32Array;
|
|
1005
|
+
hex2bytes: (hex: string) => Uint8Array;
|
|
1006
|
+
bytes2hex: (bytes: Uint8Array) => string;
|
|
1007
|
+
toUint32: (str: string) => Uint32Array;
|
|
1008
|
+
fromUint32: (uint32: Uint32Array) => string;
|
|
958
1009
|
};
|
|
959
1010
|
KValue: typeof KValue;
|
|
960
1011
|
Mapping: typeof Mapping;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
bytes2str: (bytes: Uint8Array) => string;
|
|
3
|
+
str2bytes: (str?: string) => Uint8Array;
|
|
4
|
+
str2hex: (str: string) => string;
|
|
5
|
+
hex2str: (hexstr: string) => string;
|
|
6
|
+
concatBytes: (...args: Uint8Array[]) => Uint8Array;
|
|
7
|
+
uint32ToBytes: (uint32: Uint32Array) => Uint8Array;
|
|
8
|
+
bytesToUint32: (bytes: Uint8Array) => Uint32Array;
|
|
9
|
+
hex2bytes: (hex: string) => Uint8Array;
|
|
10
|
+
bytes2hex: (bytes: Uint8Array) => string;
|
|
11
|
+
toUint32: (str: string) => Uint32Array;
|
|
12
|
+
fromUint32: (uint32: Uint32Array) => string;
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
str2Hex: (str: string) => string;
|
|
3
|
-
hex2Str: (hexstr: string) => string;
|
|
4
2
|
str2ab: (content?: string, base64?: boolean) => ArrayBuffer;
|
|
5
3
|
ab2str: (data: ArrayBuffer, base64?: boolean) => string;
|
|
6
|
-
bytesToStr: (bytes: Uint8Array) => string;
|
|
7
|
-
strToBytes: (str?: string) => Uint8Array;
|
|
8
4
|
utf8ToBase64: (str: string) => string;
|
|
9
5
|
base64ToUtf8: (base64Str: string) => string;
|
|
10
6
|
getRandomBytes: (length: number) => Uint8Array;
|
|
11
7
|
textEncode: (text: string) => Uint8Array;
|
|
12
8
|
textDecode: (buf: ArrayBufferLike) => string;
|
|
13
9
|
toDataUrl: (textOrBuf: string | ArrayBuffer, contentType?: string) => string;
|
|
14
|
-
concatBytes: (...args: Uint8Array[]) => Uint8Array;
|
|
15
10
|
toBase64: (input?: string) => string;
|
|
16
11
|
fromBase64: (input?: string) => string;
|
|
17
12
|
bytesToBase64: (bytes: Uint8Array) => string;
|
|
@@ -20,5 +15,18 @@ declare const _default: {
|
|
|
20
15
|
fromUtf8: (utftext: string) => string;
|
|
21
16
|
toUtf8Bytes: (content: string) => Uint8Array;
|
|
22
17
|
fromUtf8Bytes: (utf8Bytes: Uint8Array) => string;
|
|
18
|
+
pkcs7Padding: (plaintext: Uint8Array, blockSize: number) => Uint8Array;
|
|
19
|
+
pkcs7Unpadding: (ciphertext: Uint8Array) => Uint8Array;
|
|
20
|
+
bytes2str: (bytes: Uint8Array) => string;
|
|
21
|
+
str2bytes: (str?: string) => Uint8Array;
|
|
22
|
+
str2hex: (str: string) => string;
|
|
23
|
+
hex2str: (hexstr: string) => string;
|
|
24
|
+
concatBytes: (...args: Uint8Array[]) => Uint8Array;
|
|
25
|
+
uint32ToBytes: (uint32: Uint32Array) => Uint8Array;
|
|
26
|
+
bytesToUint32: (bytes: Uint8Array) => Uint32Array;
|
|
27
|
+
hex2bytes: (hex: string) => Uint8Array;
|
|
28
|
+
bytes2hex: (bytes: Uint8Array) => string;
|
|
29
|
+
toUint32: (str: string) => Uint32Array;
|
|
30
|
+
fromUint32: (uint32: Uint32Array) => string;
|
|
23
31
|
};
|
|
24
32
|
export default _default;
|
|
@@ -4,6 +4,15 @@ declare const _default: {
|
|
|
4
4
|
decode: (base64Str: string) => string;
|
|
5
5
|
encodeByOss: (input: string) => string;
|
|
6
6
|
};
|
|
7
|
+
tea: {
|
|
8
|
+
encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
9
|
+
decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
10
|
+
toTeaKey: (str: string) => Uint32Array;
|
|
11
|
+
encode: (plaintext: string, key: string) => string;
|
|
12
|
+
decode: (ciphertext: string, key: string) => string;
|
|
13
|
+
encodeBytes: (plainbytes: Uint8Array, key: string) => Uint8Array;
|
|
14
|
+
decodeBytes: (cipherbytes: Uint8Array, key: string) => Uint8Array;
|
|
15
|
+
};
|
|
7
16
|
uuid: (len?: number, radix?: number) => string;
|
|
8
17
|
guid: (len: number, prefix?: boolean, sep?: string) => string;
|
|
9
18
|
getHexString: (len: number) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
3
|
+
decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
4
|
+
toTeaKey: (str: string) => Uint32Array;
|
|
5
|
+
encode: (plaintext: string, key: string) => string;
|
|
6
|
+
decode: (ciphertext: string, key: string) => string;
|
|
7
|
+
encodeBytes: (plainbytes: Uint8Array, key: string) => Uint8Array;
|
|
8
|
+
decodeBytes: (cipherbytes: Uint8Array, key: string) => Uint8Array;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|