ly-utils-lib 1.0.11 → 2.4.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/LICENSE +21 -0
- package/README.md +889 -686
- package/dist/array.cjs +237 -0
- package/dist/array.cjs.map +1 -0
- package/dist/array.d.cts +2 -0
- package/dist/array.d.ts +2 -0
- package/dist/array.js +150 -0
- package/dist/array.js.map +1 -0
- package/dist/crypto.cjs +193 -0
- package/dist/crypto.cjs.map +1 -0
- package/dist/crypto.d.cts +3 -0
- package/dist/crypto.d.ts +3 -0
- package/dist/crypto.js +144 -0
- package/dist/crypto.js.map +1 -0
- package/dist/date.cjs +563 -0
- package/dist/date.cjs.map +1 -0
- package/dist/date.d.cts +2 -0
- package/dist/date.d.ts +2 -0
- package/dist/date.js +451 -0
- package/dist/date.js.map +1 -0
- package/dist/excel.cjs +227 -0
- package/dist/excel.cjs.map +1 -0
- package/dist/excel.d.cts +2 -0
- package/dist/excel.d.ts +2 -0
- package/dist/excel.js +196 -0
- package/dist/excel.js.map +1 -0
- package/dist/index-B80SEVzM.d.cts +382 -0
- package/dist/index-B80SEVzM.d.ts +382 -0
- package/dist/index-Ba1rjTzj.d.cts +299 -0
- package/dist/index-Ba1rjTzj.d.ts +299 -0
- package/dist/index-Bg1ise7y.d.cts +253 -0
- package/dist/index-Bg1ise7y.d.ts +253 -0
- package/dist/index-BoqNpwNa.d.cts +203 -0
- package/dist/index-BoqNpwNa.d.ts +203 -0
- package/dist/index-C0qUnb9Y.d.cts +533 -0
- package/dist/index-C0qUnb9Y.d.ts +533 -0
- package/dist/index-Cy-mb5v_.d.cts +262 -0
- package/dist/index-Cy-mb5v_.d.ts +262 -0
- package/dist/index-D1f9Sym2.d.cts +148 -0
- package/dist/index-D1f9Sym2.d.ts +148 -0
- package/dist/index-Dan5oF-5.d.cts +213 -0
- package/dist/index-Dan5oF-5.d.ts +213 -0
- package/dist/index-XABfrs7z.d.cts +596 -0
- package/dist/index-XABfrs7z.d.ts +596 -0
- package/dist/index-YXWfKCK7.d.cts +109 -0
- package/dist/index-YXWfKCK7.d.ts +109 -0
- package/dist/index.cjs +3355 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +3294 -0
- package/dist/index.js.map +1 -0
- package/dist/map.cjs +839 -0
- package/dist/map.cjs.map +1 -0
- package/dist/map.d.cts +6 -0
- package/dist/map.d.ts +6 -0
- package/dist/map.js +811 -0
- package/dist/map.js.map +1 -0
- package/dist/object.cjs +316 -0
- package/dist/object.cjs.map +1 -0
- package/dist/object.d.cts +2 -0
- package/dist/object.d.ts +2 -0
- package/dist/object.js +247 -0
- package/dist/object.js.map +1 -0
- package/dist/pdf.cjs +197 -0
- package/dist/pdf.cjs.map +1 -0
- package/dist/pdf.d.cts +3 -0
- package/dist/pdf.d.ts +3 -0
- package/dist/pdf.js +173 -0
- package/dist/pdf.js.map +1 -0
- package/dist/storage.cjs +255 -0
- package/dist/storage.cjs.map +1 -0
- package/dist/storage.d.cts +1 -0
- package/dist/storage.d.ts +1 -0
- package/dist/storage.js +226 -0
- package/dist/storage.js.map +1 -0
- package/dist/string.cjs +232 -0
- package/dist/string.cjs.map +1 -0
- package/dist/string.d.cts +2 -0
- package/dist/string.d.ts +2 -0
- package/dist/string.js +170 -0
- package/dist/string.js.map +1 -0
- package/dist/utils.cjs +429 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +2 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +371 -0
- package/dist/utils.js.map +1 -0
- package/package.json +159 -33
- package/dist/ly-utils-lib.cjs.js +0 -52929
- package/dist/ly-utils-lib.cjs.js.map +0 -1
- package/dist/ly-utils-lib.es.js +0 -69623
- package/dist/ly-utils-lib.es.js.map +0 -1
- package/dist/ly-utils-lib.umd.js +0 -53314
- package/dist/ly-utils-lib.umd.js.map +0 -1
- package/dist/types/index.d.ts +0 -15
- package/dist/types/utils/esToolkit.d.ts +0 -12
- package/dist/types/utils/ol.d.ts +0 -181
- package/dist/types/utils/router.d.ts +0 -15
- package/dist/types/utils/storage.d.ts +0 -42
- package/dist/types/utils/time.d.ts +0 -76
- package/dist/types/utils/tool.d.ts +0 -86
- package/dist/vite.svg +0 -1
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage Module - 浏览器存储工具
|
|
3
|
+
*
|
|
4
|
+
* 提供统一的浏览器存储操作 API
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* 存储数据类型
|
|
8
|
+
*/
|
|
9
|
+
type StorageValue = string | number | boolean | null | undefined | object | unknown[];
|
|
10
|
+
/**
|
|
11
|
+
* 存储选项
|
|
12
|
+
*/
|
|
13
|
+
interface StorageOptions {
|
|
14
|
+
/** 过期时间(毫秒),0 表示永不过期 */
|
|
15
|
+
ttl?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Cookie 选项
|
|
19
|
+
*/
|
|
20
|
+
interface CookieOptions extends Cookies.CookieAttributes {
|
|
21
|
+
/** 过期天数 */
|
|
22
|
+
days?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 设置永久缓存
|
|
26
|
+
* @param key - 缓存名称
|
|
27
|
+
* @param value - 缓存内容
|
|
28
|
+
* @param options - 存储选项
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* setLocal('user', { name: 'Alice', age: 25 })
|
|
32
|
+
* setLocal('token', 'abc123', { ttl: 3600000 }) // 1小时后过期
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare function setLocal<T = StorageValue>(key: string, value: T, options?: StorageOptions): void;
|
|
36
|
+
/**
|
|
37
|
+
* 获取永久缓存
|
|
38
|
+
* @param key - 缓存名称
|
|
39
|
+
* @returns 缓存内容,不存在或已过期返回 undefined
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const user = getLocal<{ name: string; age: number }>('user')
|
|
43
|
+
* console.log(user?.name) // 'Alice'
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare function getLocal<T = StorageValue>(key: string): T | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* 移除永久缓存
|
|
49
|
+
* @param key - 缓存名称
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* removeLocal('user')
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
declare function removeLocal(key: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* 移除全部永久缓存
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* clearLocal()
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
declare function clearLocal(): void;
|
|
64
|
+
/**
|
|
65
|
+
* 获取所有 localStorage 的键
|
|
66
|
+
* @returns 键数组
|
|
67
|
+
*/
|
|
68
|
+
declare function getLocalKeys(): string[];
|
|
69
|
+
/**
|
|
70
|
+
* 获取 localStorage 中键的数量
|
|
71
|
+
* @returns 键的数量
|
|
72
|
+
*/
|
|
73
|
+
declare function getLocalSize(): number;
|
|
74
|
+
/**
|
|
75
|
+
* 设置临时缓存
|
|
76
|
+
* @param key - 缓存名称
|
|
77
|
+
* @param value - 缓存内容
|
|
78
|
+
* @param options - 存储选项
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* setSession('temp', { data: [1, 2, 3] })
|
|
82
|
+
* setSession('session', 'abc123', { ttl: 60000 }) // 1分钟后过期
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
declare function setSession<T = StorageValue>(key: string, value: T, options?: StorageOptions): void;
|
|
86
|
+
/**
|
|
87
|
+
* 获取临时缓存
|
|
88
|
+
* @param key - 缓存名称
|
|
89
|
+
* @returns 缓存内容,不存在或已过期返回 undefined
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* const temp = getSession<{ data: number[] }>('temp')
|
|
93
|
+
* console.log(temp?.data) // [1, 2, 3]
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
declare function getSession<T = StorageValue>(key: string): T | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* 移除临时缓存
|
|
99
|
+
* @param key - 缓存名称
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* removeSession('temp')
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
declare function removeSession(key: string): void;
|
|
106
|
+
/**
|
|
107
|
+
* 移除全部临时缓存
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* clearSession()
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
declare function clearSession(): void;
|
|
114
|
+
/**
|
|
115
|
+
* 获取所有 sessionStorage 的键
|
|
116
|
+
* @returns 键数组
|
|
117
|
+
*/
|
|
118
|
+
declare function getSessionKeys(): string[];
|
|
119
|
+
/**
|
|
120
|
+
* 获取 sessionStorage 中键的数量
|
|
121
|
+
* @returns 键的数量
|
|
122
|
+
*/
|
|
123
|
+
declare function getSessionSize(): number;
|
|
124
|
+
/**
|
|
125
|
+
* 设置 Cookie
|
|
126
|
+
* @param key - Cookie 名称
|
|
127
|
+
* @param value - Cookie 值
|
|
128
|
+
* @param options - Cookie 选项
|
|
129
|
+
* @example
|
|
130
|
+
* ```ts
|
|
131
|
+
* setCookie('token', 'abc123', { days: 7 })
|
|
132
|
+
* setCookie('user', { name: 'Alice' }, { secure: true }) // 自动序列化对象
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
declare function setCookie(key: string, value: string | object, options?: CookieOptions): void;
|
|
136
|
+
/**
|
|
137
|
+
* 获取 Cookie
|
|
138
|
+
* @param key - Cookie 名称
|
|
139
|
+
* @returns Cookie 值,不存在返回 undefined
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* const token = getCookie('token')
|
|
143
|
+
* console.log(token) // 'abc123'
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
declare function getCookie(key: string): string | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* 移除 Cookie
|
|
149
|
+
* @param key - Cookie 名称
|
|
150
|
+
* @param options - Cookie 选项(需要匹配设置时的 path 和 domain)
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* removeCookie('token')
|
|
154
|
+
* removeCookie('user', { path: '/', domain: '.example.com' })
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
declare function removeCookie(key: string, options?: CookieOptions): void;
|
|
158
|
+
/**
|
|
159
|
+
* 获取所有 Cookie
|
|
160
|
+
* @returns Cookie 对象
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* const cookies = getAllCookies()
|
|
164
|
+
* console.log(cookies) // { token: 'abc123', user: '{"name":"Alice"}' }
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
declare function getAllCookies(): Record<string, string>;
|
|
168
|
+
/**
|
|
169
|
+
* 检查 Cookie 是否存在
|
|
170
|
+
* @param key - Cookie 名称
|
|
171
|
+
* @returns 是否存在
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* if (hasCookie('token')) {
|
|
175
|
+
* console.log('Token exists')
|
|
176
|
+
* }
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
declare function hasCookie(key: string): boolean;
|
|
180
|
+
/**
|
|
181
|
+
* 获取 JSON 格式的 Cookie
|
|
182
|
+
* @param key - Cookie 名称
|
|
183
|
+
* @returns 解析后的对象,不存在或解析失败返回 undefined
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* const user = getCookieJSON<{ name: string; age: number }>('user')
|
|
187
|
+
* console.log(user?.name) // 'Alice'
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
declare function getCookieJSON<T = object>(key: string): T | undefined;
|
|
191
|
+
/**
|
|
192
|
+
* 设置 JSON 格式的 Cookie(自动序列化)
|
|
193
|
+
* @param key - Cookie 名称
|
|
194
|
+
* @param value - 对象值
|
|
195
|
+
* @param options - Cookie 选项
|
|
196
|
+
* @example
|
|
197
|
+
* ```ts
|
|
198
|
+
* setCookieJSON('user', { name: 'Alice', age: 25 }, { days: 7 })
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
declare function setCookieJSON<T = object>(key: string, value: T, options?: CookieOptions): void;
|
|
202
|
+
/**
|
|
203
|
+
* 获取所有 Cookie 的数量
|
|
204
|
+
* @returns Cookie 数量
|
|
205
|
+
* @example
|
|
206
|
+
* ```ts
|
|
207
|
+
* console.log(getCookieSize()) // 3
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
declare function getCookieSize(): number;
|
|
211
|
+
/**
|
|
212
|
+
* 存储类型
|
|
213
|
+
*/
|
|
214
|
+
type StorageType = 'local' | 'session' | 'cookie';
|
|
215
|
+
/**
|
|
216
|
+
* 统一设置存储
|
|
217
|
+
* @param type - 存储类型
|
|
218
|
+
* @param key - 键
|
|
219
|
+
* @param value - 值
|
|
220
|
+
* @param options - 选项
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* setStorage('local', 'user', { name: 'Alice' })
|
|
224
|
+
* setStorage('cookie', 'token', 'abc123', { days: 7 })
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
declare function setStorage<T extends string | object>(type: 'local', key: string, value: T, options?: StorageOptions): void;
|
|
228
|
+
declare function setStorage<T extends string | object>(type: 'session', key: string, value: T, options?: StorageOptions): void;
|
|
229
|
+
declare function setStorage<T extends string | object>(type: 'cookie', key: string, value: T, options?: CookieOptions): void;
|
|
230
|
+
/**
|
|
231
|
+
* 统一获取存储
|
|
232
|
+
* @param type - 存储类型
|
|
233
|
+
* @param key - 键
|
|
234
|
+
* @returns 值
|
|
235
|
+
* @example
|
|
236
|
+
* ```ts
|
|
237
|
+
* const user = getStorage<{ name: string }>('local', 'user')
|
|
238
|
+
* const token = getStorage('cookie', 'token')
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
declare function getStorage<T = StorageValue>(type: 'local', key: string): T | undefined;
|
|
242
|
+
declare function getStorage<T = StorageValue>(type: 'session', key: string): T | undefined;
|
|
243
|
+
declare function getStorage(type: 'cookie', key: string): string | undefined;
|
|
244
|
+
/**
|
|
245
|
+
* 统一移除存储
|
|
246
|
+
* @param type - 存储类型
|
|
247
|
+
* @param key - 键
|
|
248
|
+
* @example
|
|
249
|
+
* ```ts
|
|
250
|
+
* removeStorage('local', 'user')
|
|
251
|
+
* removeStorage('cookie', 'token')
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
declare function removeStorage(type: StorageType, key: string): void;
|
|
255
|
+
/**
|
|
256
|
+
* 统一清除存储
|
|
257
|
+
* @param type - 存储类型
|
|
258
|
+
* @example
|
|
259
|
+
* ```ts
|
|
260
|
+
* clearStorage('local')
|
|
261
|
+
* clearStorage('session')
|
|
262
|
+
* clearStorage('cookie') // 注意:cookie 只能逐个删除
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
declare function clearStorage(type: StorageType): void;
|
|
266
|
+
|
|
267
|
+
type index_CookieOptions = CookieOptions;
|
|
268
|
+
type index_StorageOptions = StorageOptions;
|
|
269
|
+
type index_StorageType = StorageType;
|
|
270
|
+
type index_StorageValue = StorageValue;
|
|
271
|
+
declare const index_clearLocal: typeof clearLocal;
|
|
272
|
+
declare const index_clearSession: typeof clearSession;
|
|
273
|
+
declare const index_clearStorage: typeof clearStorage;
|
|
274
|
+
declare const index_getAllCookies: typeof getAllCookies;
|
|
275
|
+
declare const index_getCookie: typeof getCookie;
|
|
276
|
+
declare const index_getCookieJSON: typeof getCookieJSON;
|
|
277
|
+
declare const index_getCookieSize: typeof getCookieSize;
|
|
278
|
+
declare const index_getLocal: typeof getLocal;
|
|
279
|
+
declare const index_getLocalKeys: typeof getLocalKeys;
|
|
280
|
+
declare const index_getLocalSize: typeof getLocalSize;
|
|
281
|
+
declare const index_getSession: typeof getSession;
|
|
282
|
+
declare const index_getSessionKeys: typeof getSessionKeys;
|
|
283
|
+
declare const index_getSessionSize: typeof getSessionSize;
|
|
284
|
+
declare const index_getStorage: typeof getStorage;
|
|
285
|
+
declare const index_hasCookie: typeof hasCookie;
|
|
286
|
+
declare const index_removeCookie: typeof removeCookie;
|
|
287
|
+
declare const index_removeLocal: typeof removeLocal;
|
|
288
|
+
declare const index_removeSession: typeof removeSession;
|
|
289
|
+
declare const index_removeStorage: typeof removeStorage;
|
|
290
|
+
declare const index_setCookie: typeof setCookie;
|
|
291
|
+
declare const index_setCookieJSON: typeof setCookieJSON;
|
|
292
|
+
declare const index_setLocal: typeof setLocal;
|
|
293
|
+
declare const index_setSession: typeof setSession;
|
|
294
|
+
declare const index_setStorage: typeof setStorage;
|
|
295
|
+
declare namespace index {
|
|
296
|
+
export { type index_CookieOptions as CookieOptions, type index_StorageOptions as StorageOptions, type index_StorageType as StorageType, type index_StorageValue as StorageValue, index_clearLocal as clearLocal, index_clearSession as clearSession, index_clearStorage as clearStorage, index_getAllCookies as getAllCookies, index_getCookie as getCookie, index_getCookieJSON as getCookieJSON, index_getCookieSize as getCookieSize, index_getLocal as getLocal, index_getLocalKeys as getLocalKeys, index_getLocalSize as getLocalSize, index_getSession as getSession, index_getSessionKeys as getSessionKeys, index_getSessionSize as getSessionSize, index_getStorage as getStorage, index_hasCookie as hasCookie, index_removeCookie as removeCookie, index_removeLocal as removeLocal, index_removeSession as removeSession, index_removeStorage as removeStorage, index_setCookie as setCookie, index_setCookieJSON as setCookieJSON, index_setLocal as setLocal, index_setSession as setSession, index_setStorage as setStorage };
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export { setStorage as A, type CookieOptions as C, type StorageOptions as S, type StorageType as a, type StorageValue as b, clearLocal as c, clearSession as d, clearStorage as e, getCookie as f, getAllCookies as g, getCookieJSON as h, index as i, getCookieSize as j, getLocal as k, getLocalKeys as l, getLocalSize as m, getSession as n, getSessionKeys as o, getSessionSize as p, getStorage as q, hasCookie as r, removeCookie as s, removeLocal as t, removeSession as u, removeStorage as v, setCookie as w, setCookieJSON as x, setLocal as y, setSession as z };
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import * as cryptoJs from 'crypto-js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 加密解密模块
|
|
5
|
+
* 基于 crypto-js 提供常用的加密解密功能
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 加密模式类型
|
|
10
|
+
*/
|
|
11
|
+
type CryptoMode = any;
|
|
12
|
+
/**
|
|
13
|
+
* 填充方式类型
|
|
14
|
+
*/
|
|
15
|
+
type CryptoPadding = any;
|
|
16
|
+
/**
|
|
17
|
+
* MD5 加密
|
|
18
|
+
* @param message 要加密的消息
|
|
19
|
+
* @returns MD5 哈希值
|
|
20
|
+
*/
|
|
21
|
+
declare const md5: (message: string) => string;
|
|
22
|
+
/**
|
|
23
|
+
* SHA1 加密
|
|
24
|
+
* @param message 要加密的消息
|
|
25
|
+
* @returns SHA1 哈希值
|
|
26
|
+
*/
|
|
27
|
+
declare const sha1: (message: string) => string;
|
|
28
|
+
/**
|
|
29
|
+
* SHA256 加密
|
|
30
|
+
* @param message 要加密的消息
|
|
31
|
+
* @returns SHA256 哈希值
|
|
32
|
+
*/
|
|
33
|
+
declare const sha256: (message: string) => string;
|
|
34
|
+
/**
|
|
35
|
+
* SHA512 加密
|
|
36
|
+
* @param message 要加密的消息
|
|
37
|
+
* @returns SHA512 哈希值
|
|
38
|
+
*/
|
|
39
|
+
declare const sha512: (message: string) => string;
|
|
40
|
+
/**
|
|
41
|
+
* Hmac-MD5 加密
|
|
42
|
+
* @param message 要加密的消息
|
|
43
|
+
* @param key 密钥
|
|
44
|
+
* @returns Hmac-MD5 哈希值
|
|
45
|
+
*/
|
|
46
|
+
declare const hmacMD5: (message: string, key: string) => string;
|
|
47
|
+
/**
|
|
48
|
+
* Hmac-SHA1 加密
|
|
49
|
+
* @param message 要加密的消息
|
|
50
|
+
* @param key 密钥
|
|
51
|
+
* @returns Hmac-SHA1 哈希值
|
|
52
|
+
*/
|
|
53
|
+
declare const hmacSHA1: (message: string, key: string) => string;
|
|
54
|
+
/**
|
|
55
|
+
* Hmac-SHA256 加密
|
|
56
|
+
* @param message 要加密的消息
|
|
57
|
+
* @param key 密钥
|
|
58
|
+
* @returns Hmac-SHA256 哈希值
|
|
59
|
+
*/
|
|
60
|
+
declare const hmacSHA256: (message: string, key: string) => string;
|
|
61
|
+
/**
|
|
62
|
+
* Hmac-SHA512 加密
|
|
63
|
+
* @param message 要加密的消息
|
|
64
|
+
* @param key 密钥
|
|
65
|
+
* @returns Hmac-SHA512 哈希值
|
|
66
|
+
*/
|
|
67
|
+
declare const hmacSHA512: (message: string, key: string) => string;
|
|
68
|
+
/**
|
|
69
|
+
* AES 加密
|
|
70
|
+
* @param message 要加密的消息
|
|
71
|
+
* @param key 密钥(16/24/32 字节)
|
|
72
|
+
* @param iv 初始向量(可选,16 字节)
|
|
73
|
+
* @param mode 加密模式(默认 CBC)
|
|
74
|
+
* @param padding 填充方式(默认 Pkcs7)
|
|
75
|
+
* @returns 加密后的密文(Base64 格式)
|
|
76
|
+
*/
|
|
77
|
+
declare const aesEncrypt: (message: string, key: string, iv?: string, mode?: CryptoMode, padding?: CryptoPadding) => string;
|
|
78
|
+
/**
|
|
79
|
+
* AES 解密
|
|
80
|
+
* @param ciphertext 密文(Base64 格式)
|
|
81
|
+
* @param key 密钥(16/24/32 字节)
|
|
82
|
+
* @param iv 初始向量(可选,16 字节)
|
|
83
|
+
* @param mode 加密模式(默认 CBC)
|
|
84
|
+
* @param padding 填充方式(默认 Pkcs7)
|
|
85
|
+
* @returns 解密后的明文
|
|
86
|
+
*/
|
|
87
|
+
declare const aesDecrypt: (ciphertext: string, key: string, iv?: string, mode?: CryptoMode, padding?: CryptoPadding) => string;
|
|
88
|
+
/**
|
|
89
|
+
* DES 加密
|
|
90
|
+
* @param message 要加密的消息
|
|
91
|
+
* @param key 密钥(8 字节)
|
|
92
|
+
* @param iv 初始向量(可选,8 字节)
|
|
93
|
+
* @param mode 加密模式(默认 CBC)
|
|
94
|
+
* @param padding 填充方式(默认 Pkcs7)
|
|
95
|
+
* @returns 加密后的密文(Base64 格式)
|
|
96
|
+
*/
|
|
97
|
+
declare const desEncrypt: (message: string, key: string, iv?: string, mode?: CryptoMode, padding?: CryptoPadding) => string;
|
|
98
|
+
/**
|
|
99
|
+
* DES 解密
|
|
100
|
+
* @param ciphertext 密文(Base64 格式)
|
|
101
|
+
* @param key 密钥(8 字节)
|
|
102
|
+
* @param iv 初始向量(可选,8 字节)
|
|
103
|
+
* @param mode 加密模式(默认 CBC)
|
|
104
|
+
* @param padding 填充方式(默认 Pkcs7)
|
|
105
|
+
* @returns 解密后的明文
|
|
106
|
+
*/
|
|
107
|
+
declare const desDecrypt: (ciphertext: string, key: string, iv?: string, mode?: CryptoMode, padding?: CryptoPadding) => string;
|
|
108
|
+
/**
|
|
109
|
+
* Triple DES (3DES) 加密
|
|
110
|
+
* @param message 要加密的消息
|
|
111
|
+
* @param key 密钥(24 字节)
|
|
112
|
+
* @param iv 初始向量(可选,8 字节)
|
|
113
|
+
* @param mode 加密模式(默认 CBC)
|
|
114
|
+
* @param padding 填充方式(默认 Pkcs7)
|
|
115
|
+
* @returns 加密后的密文(Base64 格式)
|
|
116
|
+
*/
|
|
117
|
+
declare const tripleDesEncrypt: (message: string, key: string, iv?: string, mode?: CryptoMode, padding?: CryptoPadding) => string;
|
|
118
|
+
/**
|
|
119
|
+
* Triple DES (3DES) 解密
|
|
120
|
+
* @param ciphertext 密文(Base64 格式)
|
|
121
|
+
* @param key 密钥(24 字节)
|
|
122
|
+
* @param iv 初始向量(可选,8 字节)
|
|
123
|
+
* @param mode 加密模式(默认 CBC)
|
|
124
|
+
* @param padding 填充方式(默认 Pkcs7)
|
|
125
|
+
* @returns 解密后的明文
|
|
126
|
+
*/
|
|
127
|
+
declare const tripleDesDecrypt: (ciphertext: string, key: string, iv?: string, mode?: CryptoMode, padding?: CryptoPadding) => string;
|
|
128
|
+
/**
|
|
129
|
+
* RC4 加密
|
|
130
|
+
* @param message 要加密的消息
|
|
131
|
+
* @param key 密钥
|
|
132
|
+
* @returns 加密后的密文(Base64 格式)
|
|
133
|
+
*/
|
|
134
|
+
declare const rc4Encrypt: (message: string, key: string) => string;
|
|
135
|
+
/**
|
|
136
|
+
* RC4 解密
|
|
137
|
+
* @param ciphertext 密文(Base64 格式)
|
|
138
|
+
* @param key 密钥
|
|
139
|
+
* @returns 解密后的明文
|
|
140
|
+
*/
|
|
141
|
+
declare const rc4Decrypt: (ciphertext: string, key: string) => string;
|
|
142
|
+
/**
|
|
143
|
+
* Rabbit 加密
|
|
144
|
+
* @param message 要加密的消息
|
|
145
|
+
* @param key 密钥
|
|
146
|
+
* @returns 加密后的密文(Base64 格式)
|
|
147
|
+
*/
|
|
148
|
+
declare const rabbitEncrypt: (message: string, key: string) => string;
|
|
149
|
+
/**
|
|
150
|
+
* Rabbit 解密
|
|
151
|
+
* @param ciphertext 密文(Base64 格式)
|
|
152
|
+
* @param key 密钥
|
|
153
|
+
* @returns 解密后的明文
|
|
154
|
+
*/
|
|
155
|
+
declare const rabbitDecrypt: (ciphertext: string, key: string) => string;
|
|
156
|
+
/**
|
|
157
|
+
* Base64 编码
|
|
158
|
+
* @param message 要编码的消息
|
|
159
|
+
* @returns Base64 编码后的字符串
|
|
160
|
+
*/
|
|
161
|
+
declare const base64Encode: (message: string) => string;
|
|
162
|
+
/**
|
|
163
|
+
* Base64 解码
|
|
164
|
+
* @param encoded Base64 编码的字符串
|
|
165
|
+
* @returns 解码后的原始消息
|
|
166
|
+
*/
|
|
167
|
+
declare const base64Decode: (encoded: string) => string;
|
|
168
|
+
/**
|
|
169
|
+
* UTF-8 编码
|
|
170
|
+
* @param message 要编码的消息
|
|
171
|
+
* @returns UTF-8 编码后的字符串
|
|
172
|
+
*/
|
|
173
|
+
declare const utf8Encode: (message: string) => string;
|
|
174
|
+
/**
|
|
175
|
+
* UTF-8 解码
|
|
176
|
+
* @param encoded UTF-8 编码的字符串
|
|
177
|
+
* @returns 解码后的原始消息
|
|
178
|
+
*/
|
|
179
|
+
declare const utf8Decode: (encoded: string) => string;
|
|
180
|
+
/**
|
|
181
|
+
* Hex 编码
|
|
182
|
+
* @param message 要编码的消息
|
|
183
|
+
* @returns Hex 编码后的字符串
|
|
184
|
+
*/
|
|
185
|
+
declare const hexEncode: (message: string) => string;
|
|
186
|
+
/**
|
|
187
|
+
* Hex 解码
|
|
188
|
+
* @param encoded Hex 编码的字符串
|
|
189
|
+
* @returns 解码后的原始消息
|
|
190
|
+
*/
|
|
191
|
+
declare const hexDecode: (encoded: string) => string;
|
|
192
|
+
/**
|
|
193
|
+
* 生成随机密钥
|
|
194
|
+
* @param length 密钥长度(字节)
|
|
195
|
+
* @returns 随机密钥(Base64 格式)
|
|
196
|
+
*/
|
|
197
|
+
declare const generateKey: (length?: number) => string;
|
|
198
|
+
/**
|
|
199
|
+
* 生成随机 IV(初始向量)
|
|
200
|
+
* @param length IV 长度(字节,默认 16)
|
|
201
|
+
* @returns 随机 IV(Base64 格式)
|
|
202
|
+
*/
|
|
203
|
+
declare const generateIV: (length?: number) => string;
|
|
204
|
+
/**
|
|
205
|
+
* PBKDF2 密钥派生
|
|
206
|
+
* @param password 密码
|
|
207
|
+
* @param salt 盐值
|
|
208
|
+
* @param iterations 迭代次数
|
|
209
|
+
* @param keySize 密钥长度(字节)
|
|
210
|
+
* @returns 派生的密钥(Hex 格式)
|
|
211
|
+
*/
|
|
212
|
+
declare const pbkdf2: (password: string, salt: string, iterations?: number, keySize?: number) => string;
|
|
213
|
+
/**
|
|
214
|
+
* 生成 UUID v4
|
|
215
|
+
* @returns UUID 字符串
|
|
216
|
+
*/
|
|
217
|
+
declare const uuid: () => string;
|
|
218
|
+
|
|
219
|
+
type index_CryptoMode = CryptoMode;
|
|
220
|
+
type index_CryptoPadding = CryptoPadding;
|
|
221
|
+
declare const index_aesDecrypt: typeof aesDecrypt;
|
|
222
|
+
declare const index_aesEncrypt: typeof aesEncrypt;
|
|
223
|
+
declare const index_base64Decode: typeof base64Decode;
|
|
224
|
+
declare const index_base64Encode: typeof base64Encode;
|
|
225
|
+
declare const index_desDecrypt: typeof desDecrypt;
|
|
226
|
+
declare const index_desEncrypt: typeof desEncrypt;
|
|
227
|
+
declare const index_generateIV: typeof generateIV;
|
|
228
|
+
declare const index_generateKey: typeof generateKey;
|
|
229
|
+
declare const index_hexDecode: typeof hexDecode;
|
|
230
|
+
declare const index_hexEncode: typeof hexEncode;
|
|
231
|
+
declare const index_hmacMD5: typeof hmacMD5;
|
|
232
|
+
declare const index_hmacSHA1: typeof hmacSHA1;
|
|
233
|
+
declare const index_hmacSHA256: typeof hmacSHA256;
|
|
234
|
+
declare const index_hmacSHA512: typeof hmacSHA512;
|
|
235
|
+
declare const index_md5: typeof md5;
|
|
236
|
+
declare const index_pbkdf2: typeof pbkdf2;
|
|
237
|
+
declare const index_rabbitDecrypt: typeof rabbitDecrypt;
|
|
238
|
+
declare const index_rabbitEncrypt: typeof rabbitEncrypt;
|
|
239
|
+
declare const index_rc4Decrypt: typeof rc4Decrypt;
|
|
240
|
+
declare const index_rc4Encrypt: typeof rc4Encrypt;
|
|
241
|
+
declare const index_sha1: typeof sha1;
|
|
242
|
+
declare const index_sha256: typeof sha256;
|
|
243
|
+
declare const index_sha512: typeof sha512;
|
|
244
|
+
declare const index_tripleDesDecrypt: typeof tripleDesDecrypt;
|
|
245
|
+
declare const index_tripleDesEncrypt: typeof tripleDesEncrypt;
|
|
246
|
+
declare const index_utf8Decode: typeof utf8Decode;
|
|
247
|
+
declare const index_utf8Encode: typeof utf8Encode;
|
|
248
|
+
declare const index_uuid: typeof uuid;
|
|
249
|
+
declare namespace index {
|
|
250
|
+
export { cryptoJs as CryptoJS, type index_CryptoMode as CryptoMode, type index_CryptoPadding as CryptoPadding, index_aesDecrypt as aesDecrypt, index_aesEncrypt as aesEncrypt, index_base64Decode as base64Decode, index_base64Encode as base64Encode, index_desDecrypt as desDecrypt, index_desEncrypt as desEncrypt, index_generateIV as generateIV, index_generateKey as generateKey, index_hexDecode as hexDecode, index_hexEncode as hexEncode, index_hmacMD5 as hmacMD5, index_hmacSHA1 as hmacSHA1, index_hmacSHA256 as hmacSHA256, index_hmacSHA512 as hmacSHA512, index_md5 as md5, index_pbkdf2 as pbkdf2, index_rabbitDecrypt as rabbitDecrypt, index_rabbitEncrypt as rabbitEncrypt, index_rc4Decrypt as rc4Decrypt, index_rc4Encrypt as rc4Encrypt, index_sha1 as sha1, index_sha256 as sha256, index_sha512 as sha512, index_tripleDesDecrypt as tripleDesDecrypt, index_tripleDesEncrypt as tripleDesEncrypt, index_utf8Decode as utf8Decode, index_utf8Encode as utf8Encode, index_uuid as uuid };
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export { tripleDesEncrypt as A, utf8Decode as B, type CryptoMode as C, utf8Encode as D, uuid as E, type CryptoPadding as a, aesDecrypt as b, aesEncrypt as c, base64Decode as d, base64Encode as e, desDecrypt as f, desEncrypt as g, generateIV as h, index as i, generateKey as j, hexDecode as k, hexEncode as l, hmacMD5 as m, hmacSHA1 as n, hmacSHA256 as o, hmacSHA512 as p, md5 as q, pbkdf2 as r, rabbitDecrypt as s, rabbitEncrypt as t, rc4Decrypt as u, rc4Encrypt as v, sha1 as w, sha256 as x, sha512 as y, tripleDesDecrypt as z };
|