knight-web 2.0.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.
@@ -0,0 +1,36 @@
1
+ import React from "react";
2
+ import { Knight } from "../core";
3
+ /** 抽象对象基类 */
4
+ export declare abstract class AbstractObject<Props extends AbstractObjectProps = AbstractObjectProps> extends React.Component<Props, Props> {
5
+ /** 组件ID */
6
+ protected id: string;
7
+ /** Knight实例 */
8
+ protected get knight(): Knight;
9
+ /** 构造函数 */
10
+ constructor(props: Props);
11
+ /** 组件挂载 */
12
+ componentDidMount(): void;
13
+ /** 组件刷新 */
14
+ componentDidUpdate(prevProps: Readonly<Props>, prevState: Readonly<Props>, snapshot?: any): void;
15
+ /** 组件是否应该刷新 */
16
+ shouldComponentUpdate(nextProps: Readonly<Props>, nextState?: Readonly<Props>, nextContext?: any): boolean;
17
+ /** 组件卸载 */
18
+ componentWillUnmount(): void;
19
+ /** 组件捕获 */
20
+ componentDidCatch(error: any, errorInfo: any): boolean;
21
+ /** 组件渲染 */
22
+ render(): React.ReactElement;
23
+ /** 加载 */
24
+ protected abstract OnLoad(): void;
25
+ /** 卸载 */
26
+ protected abstract OnDestroy(): void;
27
+ /** 刷新 */
28
+ protected abstract OnUpdate(prevProps: Readonly<Props>, prevState: Readonly<Props>): void;
29
+ /** 提交渲染 */
30
+ protected abstract OnRender(): React.ReactElement;
31
+ }
32
+ /** 抽象属性接口 */
33
+ export declare abstract class AbstractObjectProps implements React.HTMLAttributes<HTMLDivElement>, React.ClassAttributes<HTMLDivElement> {
34
+ /** 自定义属性 */
35
+ [key: string]: any;
36
+ }
@@ -0,0 +1,4 @@
1
+ import { AbstractObject } from "./AbstractObject";
2
+ /** 抽象界面基类 */
3
+ export declare abstract class AbstractPanel extends AbstractObject {
4
+ }
@@ -0,0 +1,2 @@
1
+ export * from './AbstractObject';
2
+ export * from './AbstractPanel';
@@ -0,0 +1,42 @@
1
+ import { BrowserUtility, InputUtility, NetworkUtility, ObjectUtility } from '../utility';
2
+ import { AbstractObject } from '../base';
3
+ export declare class Knight {
4
+ /** 全局单例 */
5
+ private static instance;
6
+ static get Instance(): Knight;
7
+ /** 根容器 */
8
+ private htmlRoot;
9
+ /** 渲染器 */
10
+ private renderer;
11
+ /** 配置 */
12
+ private config;
13
+ /** 全局对象池 */
14
+ get Objects(): ObjectUtility.MapPool<AbstractObject>;
15
+ private _objects;
16
+ /** 全局事件系统 */
17
+ get Event(): ObjectUtility.EventSystem;
18
+ private _event;
19
+ /** 路由历史数据 */
20
+ get History(): BrowserUtility.BrowserHistory;
21
+ private _history;
22
+ /** 本地路由数据 */
23
+ get Location(): BrowserUtility.BrowserLocation;
24
+ private _location;
25
+ /** 本地缓存数据 */
26
+ get Storage(): BrowserUtility.LocalStorage;
27
+ private _storage;
28
+ /** 本地Cookie数据 */
29
+ get Cookie(): BrowserUtility.BrowserCookie;
30
+ private _cookie;
31
+ /** 全局数据 */
32
+ get GlobalData(): ObjectUtility.MapPool<object>;
33
+ private _globalData;
34
+ /** 网络接口 */
35
+ get NetWork(): NetworkUtility.NetWork;
36
+ private _network;
37
+ /** 输入接口 */
38
+ get Input(): InputUtility.Input;
39
+ private _input;
40
+ /** 构造函数 */
41
+ private constructor();
42
+ }
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import { AbstractObject } from "../base";
3
+ import { InterfaceUtility } from "../utility";
4
+ /** 导航工具 */
5
+ export declare class Navgation {
6
+ /** 导航配置池 */
7
+ private static navgations;
8
+ /** 注册导航
9
+ * @param option 导航配置
10
+ */
11
+ static OnRegist(option: NavgationOption): Function;
12
+ /** 构建路由 */
13
+ static OnRender(): React.ReactElement;
14
+ }
15
+ /** 导航配置 */
16
+ export interface NavgationOption {
17
+ /** 路径
18
+ * 格式:aaa/bbb/ccc
19
+ */
20
+ path?: string;
21
+ }
22
+ /** 导航配置 */
23
+ export interface NavgationConfig extends NavgationOption {
24
+ /** 组件元素 */
25
+ type: InterfaceUtility.IType<AbstractObject>;
26
+ }
@@ -0,0 +1,2 @@
1
+ export * from './Knight';
2
+ export * from './Navgation';
@@ -0,0 +1,3 @@
1
+ export * as Core from "./core";
2
+ export * as Base from "./base";
3
+ export * as Utility from "./utility";
@@ -0,0 +1,320 @@
1
+ import PathToRegexp from "path-to-regexp";
2
+ /** 浏览器工具 */
3
+ export declare namespace BrowserUtility {
4
+ /** 标记 */
5
+ export const _mark: string;
6
+ /**
7
+ * 加载远端脚本
8
+ * @param _srcPath 远程脚本路径
9
+ * @param _name 所需返回的类实例名称
10
+ * @returns 加载脚本的实例
11
+ */
12
+ export function LoadScript<T extends object>(_srcPath: string, _name: string): Promise<T>;
13
+ /** 创建HTML元素 */
14
+ export function CreatHTMLElement(_type: string, _id: string, _name: string, _position: "relative" | "absolute", _activePointer?: boolean, _showMark?: boolean, _parent?: HTMLElement): HTMLElement;
15
+ /** 剪切板管理 */
16
+ export class Clipboard {
17
+ /** 读取剪切板 */
18
+ static read(): Promise<ClipboardItems>;
19
+ /** 读取剪切板文本 */
20
+ static readText(): Promise<string>;
21
+ /** 写入剪切板 */
22
+ static write(data: ClipboardItems): Promise<void>;
23
+ /** 写入剪切板文本 */
24
+ static writeText(data: string): Promise<void>;
25
+ }
26
+ /** 本地化接口 */
27
+ export interface ILocation extends Location {
28
+ /** 协议(exp:http) */
29
+ protocol: string;
30
+ /** 超链接(http://全路由地址) */
31
+ href: string;
32
+ /** 原始链接(http://IP:Port地址) */
33
+ readonly origin: string;
34
+ /** 主机地址(IP:Port地址) */
35
+ host: string;
36
+ /** 主机名(IP) */
37
+ hostname: string;
38
+ /** 端口号(Port) */
39
+ port: string;
40
+ /** 路径名(/aaa/bbb不包含参数) */
41
+ pathname: string;
42
+ /** 搜索参数(路由参数) */
43
+ search: string;
44
+ /** 哈希地址 */
45
+ hash: string;
46
+ /** 导航到URL */
47
+ assign(url: string | URL): void;
48
+ /** 重新加载当前页面 */
49
+ reload(): void;
50
+ /** 从会话历史中删除当前页面并导航到给定的URL */
51
+ replace(url: string | URL): void;
52
+ }
53
+ /** 历史接口 */
54
+ export interface IHistory extends History {
55
+ /** 长度 */
56
+ readonly length: number;
57
+ /** 滚动恢复 */
58
+ scrollRestoration: ScrollRestoration;
59
+ /** 状态 */
60
+ readonly state: any;
61
+ /** 返回函数 */
62
+ back(): void;
63
+ /** 前进函数 */
64
+ forward(): void;
65
+ /** 进入函数 */
66
+ go(delta?: number): void;
67
+ /** 设置状态 */
68
+ pushState(_state: any, _title: string, _url?: string | URL | null): void;
69
+ /** 替换状态 */
70
+ replaceState(_state: any, _title: string, _url?: string | URL | null): void;
71
+ }
72
+ /** 路由Search参数 */
73
+ export interface ISearchParams {
74
+ key: string;
75
+ value: string;
76
+ }
77
+ /** 历史事件池 */
78
+ export class HistoryEventsPool {
79
+ /** 处理函数 */
80
+ private _handlers;
81
+ constructor();
82
+ Push(_fn: Function): Function;
83
+ Call(_location: Location): void;
84
+ }
85
+ /** 历史记录刷新模式 */
86
+ export enum E_HistoryUpdateType {
87
+ /** 只要路由变更刷新 */
88
+ All = 0,
89
+ /** PathName变更刷新 */
90
+ PathName = 1,
91
+ /** PathName|Search变更刷新 */
92
+ PathNameOrSearch = 2,
93
+ /** PathName|Hash变更刷新 */
94
+ PathNameOrHash = 3
95
+ }
96
+ /** 浏览器历史记录设置 */
97
+ export class BrowserHistory {
98
+ /** 监听事件池 */
99
+ private _listeners;
100
+ /** 历史记录刷新模式 */
101
+ HistoryUpdateType: E_HistoryUpdateType;
102
+ /** 记录上一个路径 */
103
+ private _recordPath;
104
+ /** 构造函数 */
105
+ constructor();
106
+ /** 监听路由变化 */
107
+ Listen(_listener: Function): Function;
108
+ /** 刷新当前路由 */
109
+ Update(): void;
110
+ /** 前进 */
111
+ Forward(): void;
112
+ /** 后退 */
113
+ Back(): void;
114
+ /** 执行 */
115
+ Go(_delta?: number): void;
116
+ /**
117
+ * 设置路由
118
+ * @param _url 设置路由路径(注意:路径前+‘/’)
119
+ * @param _searchParams 路径透传参数(key:value数组形式)
120
+ * @returns 是否设置成功
121
+ */
122
+ SetState(_url: string, _searchParams?: Array<{
123
+ key: string;
124
+ value: any;
125
+ }>): boolean;
126
+ /** 路由鉴权 */
127
+ CheckAuthorityValid(_url: string, _authentications: Array<string>): boolean;
128
+ /**
129
+ * 设置路由并刷新
130
+ * @param _url 设置路由路径(注意:路径前+‘/’)
131
+ * @param _keepAlive 是否路径持久储存
132
+ * @param _searchParams 路径透传参数(key:value数组形式)
133
+ * @returns 是否设置并刷新成功
134
+ */
135
+ SetStateUpdate(_url: string, _searchParams?: Array<{
136
+ key: string;
137
+ value: any;
138
+ }>): boolean;
139
+ /** 获取当前路由路径名 */
140
+ GetCurPathName(): string;
141
+ /** 获取路由中的参数值 */
142
+ Search<T extends object = object>(): T;
143
+ }
144
+ /** 浏览器本地设置 */
145
+ export class BrowserLocation {
146
+ /** 本地记录 */
147
+ private _location;
148
+ /** 构造函数 */
149
+ constructor();
150
+ /** 整合路由 */
151
+ private concat;
152
+ /** 打开新窗口 */
153
+ open(_url?: string | URL, target?: string, features?: string): boolean;
154
+ /** 导航到URL */
155
+ assign(_url: string, ..._params: Array<ISearchParams>): void;
156
+ /** 重新加载当前页面 */
157
+ reload(): void;
158
+ /** 从会话历史中删除当前页面并导航到给定的URL */
159
+ replace(_url: string, ..._params: Array<ISearchParams>): void;
160
+ }
161
+ /** 路径参数接口 */
162
+ export interface IPathOptions {
163
+ /** 路径 */
164
+ path?: string | any[];
165
+ exact?: boolean;
166
+ strict?: boolean;
167
+ sensitive?: boolean;
168
+ end?: boolean;
169
+ }
170
+ /** 路径管理 */
171
+ export class PathHandle {
172
+ /** 路径缓存 */
173
+ private _cache;
174
+ /** 缓存限制 */
175
+ private _cacheLimit;
176
+ /** 缓存数量 */
177
+ private _cacheCount;
178
+ /** 构造函数 */
179
+ constructor();
180
+ /** 编译路径 */
181
+ CompilePath(_path: string, _options: IPathOptions): {
182
+ regexp: RegExp;
183
+ keys: PathToRegexp.Keys;
184
+ };
185
+ /** 匹配路径(将URL路径名与路径匹配) */
186
+ MatchPath(_pathname: string, _options?: IPathOptions): string | any[] | {
187
+ path: string;
188
+ url: string;
189
+ isExact: boolean;
190
+ params: {};
191
+ };
192
+ }
193
+ /** 浏览器Cookie缓存 */
194
+ export class BrowserCookie {
195
+ /** 设置Cookie */
196
+ SetCookie(_key: string, _value: string | number, _keepDays?: number): void;
197
+ /** 获取Cookie */
198
+ GetCookie(_key: string): string;
199
+ /** 清除Cookie */
200
+ RemoveCookie(_key: string): void;
201
+ /** 清除所有Cookie */
202
+ RemoveAllCookie(): void;
203
+ }
204
+ /** 本地缓存数据 */
205
+ export class LocalStorage {
206
+ private _key;
207
+ /** 缓存数据 */
208
+ protected _handle: ILocalStorageData;
209
+ /** 构造函数 */
210
+ constructor();
211
+ /** 设置数据 */
212
+ Set(_key: string, _value: any): void;
213
+ /** 获取数据 */
214
+ Get<T extends any = any>(_key: string): T;
215
+ /** 移除数据 */
216
+ Remove(_key: string): boolean;
217
+ /** 数据是否在存在 */
218
+ Exist(_key: string): boolean;
219
+ /** 移除所有数据 */
220
+ RemoveAll(): void;
221
+ }
222
+ /** 本地缓存数据接口 */
223
+ interface ILocalStorageData {
224
+ [key: string]: any;
225
+ }
226
+ /** WebGL类
227
+ * @params 着色器
228
+ 着色器是使用 OpenGL ES 着色语言(GLSL) 编写的程序,它携带着绘制形状的顶点信息以及构造绘制在屏幕上像素的所需数据,换句话说,它负责记录着像素点的位置和颜色。
229
+ 绘制 WebGL 时候有两种不同的着色器函数,顶点着色器和片段着色器。你需要通过用 GLSL 编写这些着色器,并将代码文本传递给 WebGL,使之在 GPU 执行时编译。顺便一提,顶点着色器和片段着色器的集合我们通常称之为着色器程序。
230
+ * @params 顶点着色器
231
+ 每次渲染一个形状时,顶点着色器会在形状中的每个顶点运行。它的工作是将输入顶点从原始坐标系转换到 WebGL 使用的裁剪空间坐标系,其中每个轴的坐标范围从 -1.0 到 1.0,并且不考虑纵横比,实际尺寸或任何其他因素。
232
+ 顶点着色器需要对顶点坐标进行必要的转换,在每个顶点基础上进行其他调整或计算,然后通过将其保存在由 GLSL 提供的特殊变量(我们称为 gl_Position)中来返回变换后的顶点
233
+ 顶点着色器根据需要,也可以完成其他工作。例如,决定哪个包含 texel 面部纹理的坐标,可以应用于顶点;通过法线来确定应用到顶点的光照因子等。然后将这些信息存储在变量(varyings)或属性 (attributes)属性中,以便与片段着色器共享
234
+ * @params 片段着色器
235
+ 片段着色器在顶点着色器处理完图形的顶点后,会被要绘制的每个图形的每个像素点调用一次。它的职责是确定像素的颜色,通过指定应用到像素的纹理元素(也就是图形纹理中的像素),获取纹理元素的颜色,然后将适当的光照应用于颜色。之后颜色存储在特殊变量 gl_FragColor 中,返回到 WebGL 层。该颜色将最终绘制到屏幕上图形对应像素的对应位置。
236
+ */
237
+ export class WebGLUtility {
238
+ /** WebGL检测 */
239
+ static Check(): void;
240
+ /** 是否支持WebGL */
241
+ static OnWebGLSupported(): boolean;
242
+ /** 是否支持WebGL2 */
243
+ static OnWebGL2Supported(): boolean;
244
+ /**
245
+ * 创建着色器
246
+ * @param _context 渲染上下文
247
+ * @param _type 着色器类型
248
+ * @param _source 着色器资源
249
+ * @returns WebGL着色器
250
+ */
251
+ static OnCreatShader(_context: WebGLRenderingContext, _type: number, _source: string): WebGLShader | null;
252
+ /**
253
+ * 创建程序
254
+ * @param _context 渲染上下文
255
+ * @param _vertexShader 顶点着色器
256
+ * @param _fragShader 片元着色器
257
+ * @returns 程序实例
258
+ */
259
+ static OnCreatProgram(_context: WebGLRenderingContext, _vertexShader: string, _fragShader: string): WebGLProgram | null;
260
+ /**
261
+ * 创建程序
262
+ * @param _context 渲染上下文
263
+ * @param _vertexShader 顶点着色器
264
+ * @param _fragShader 片元着色器
265
+ * @returns 程序实例
266
+ */
267
+ static OnCreatProgramAndUse(_context: WebGLRenderingContext, _vertexShader: string, _fragShader: string): WebGLProgram | null;
268
+ /** 创建数组缓冲区并绑定数据 */
269
+ static OnCreatArrayBufferAndBind(_context: WebGLRenderingContext, _data: ArrayBufferLike | null): WebGLBuffer | null;
270
+ /** 创建元素数组缓冲区并绑定数据 */
271
+ static OnCreatElementArrayBufferAndBind(_context: WebGLRenderingContext, _data: ArrayBufferLike | null): WebGLBuffer | null;
272
+ }
273
+ /** WebGL类 */
274
+ export class WebGL {
275
+ /** 渲染目标 */
276
+ private _context;
277
+ /** 程序实例 */
278
+ private _program;
279
+ constructor(_context: WebGLRenderingContext, _vertexShader: string, _fragShader: string);
280
+ /** 创建数组缓存区并绑定 */
281
+ OnCreatArrayBufferAndBind(_source: ArrayBufferLike | null): WebGLBuffer;
282
+ /** 创建元素数组缓存区并绑定 */
283
+ OnCreatElementArrayBufferAndBind(_source: ArrayBufferLike | null): WebGLBuffer;
284
+ /** 获取属性字段引用 */
285
+ OnGetAttribLocation(_name: string): GLint;
286
+ /** 属性字段绑定缓存并启用 */
287
+ OnVertexAttribPointerAndEnable(_index: GLint, _size: GLint, _type: E_VariableType, _normalized: GLboolean, _stride: GLsizei, _offset: GLintptr): void;
288
+ /** 获取属性字段并分配缓存区 */
289
+ OnGetAttributeAndBindBuffer(_name: string, _size: GLint, _type: E_VariableType, _normalized: GLboolean, _stride: GLsizei, _offset: GLintptr): GLint;
290
+ /** 获取Uniform矩阵 */
291
+ OnGetUniformLocation(_name: string): WebGLUniformLocation | null;
292
+ /** Uniform矩阵变换4fv */
293
+ OnUniformMatrix4fv(_location: WebGLUniformLocation | null, _transpose: GLboolean, _value: Float32List): void;
294
+ /** 渲染数组 */
295
+ OnDrawArray(_renderType: E_RenderType): boolean;
296
+ /** 渲染元素 */
297
+ OnDrawElements(_renderType: E_RenderType, _count: GLsizei, _type: E_VariableType, _offset: GLintptr): boolean;
298
+ }
299
+ /** 渲染类型 */
300
+ export enum E_RenderType {
301
+ POINTS = 0,
302
+ LINES = 1,
303
+ LINE_LOOP = 2,
304
+ LINE_STRIP = 3,
305
+ TRIANGLES = 4,
306
+ TRIANGLE_STRIP = 5,
307
+ TRIANGLE_FAN = 6
308
+ }
309
+ /** 变量类型 */
310
+ export enum E_VariableType {
311
+ BYTE = 5120,
312
+ UNSIGNED_BYTE = 5121,
313
+ SHORT = 5122,
314
+ UNSIGNED_SHORT = 5123,
315
+ INT = 5124,
316
+ UNSIGNED_INT = 5125,
317
+ FLOAT = 5126
318
+ }
319
+ export {};
320
+ }
@@ -0,0 +1,33 @@
1
+ /** 配置工具 */
2
+ export declare namespace ConfigUtility {
3
+ /** 配置数据接口 */
4
+ interface IConfig {
5
+ /** 主体名称 */
6
+ name?: string;
7
+ /** 主体网址 */
8
+ website?: string;
9
+ /** 版本号 */
10
+ version?: string;
11
+ /** 账号 */
12
+ account?: string;
13
+ /** 密码 */
14
+ password?: string;
15
+ /** 调试模式 */
16
+ debugMode?: boolean;
17
+ /** 时间戳 */
18
+ timeStamp?: number;
19
+ }
20
+ /** 配置类 */
21
+ class Config {
22
+ /** 私钥 */
23
+ private privateKey;
24
+ /** 配置数据 */
25
+ private configData;
26
+ /** 创建配置 */
27
+ OnCreatToken(config: IConfig): string;
28
+ /** 获取配置 */
29
+ OnGetConfig(token: string): IConfig;
30
+ /** 检测配置 */
31
+ OnMatch(token: string): boolean;
32
+ }
33
+ }
@@ -0,0 +1,215 @@
1
+ import { Hasher, WordArray } from 'crypto-es';
2
+ import { Format } from 'crypto-es/dist/cipher-core.cjs';
3
+ import { Encoder, HasherCfg } from 'crypto-es/dist/core.cjs';
4
+ /** 加密工具类
5
+ * npm install crypto-es
6
+ * npm install @types/crypto-es
7
+ * npm install jsonwebtoken
8
+ * npm install @types/jsonwebtoken
9
+ */
10
+ export declare namespace CryptoUtility {
11
+ /** 常用Token加解密工具 */
12
+ class Token {
13
+ /**
14
+ * 验签及解析Token
15
+ * @param _cipherText
16
+ * @param _key
17
+ */
18
+ static CheckToken(_cipherText: string, _key?: string): ICheckResult;
19
+ /**
20
+ * 解析Base64URL
21
+ * @param _message
22
+ * @returns
23
+ */
24
+ static OnBase64UrlDecode(_message: string): string;
25
+ }
26
+ /** 检测结果 */
27
+ interface ICheckResult {
28
+ header: object;
29
+ payload: object;
30
+ signature: boolean;
31
+ }
32
+ /**
33
+ * AES(Advanced Encryption Standard)加密算法工具
34
+ * @introduce 最常用的对称加密算法,支持不同的密钥长度(128、192 和 256 位)
35
+ */
36
+ class _AES {
37
+ /** 获取编码转换器 */
38
+ private static OnGetEncoder;
39
+ /** 获取密文配置
40
+ * CBC、CFB、OFB、CTR模式必须提供IV,ECB模式不能提供IV
41
+ * IV长度通常为16字节(128位)
42
+ */
43
+ private static OnGetCipherCfg;
44
+ /**
45
+ * 加密
46
+ * @param context 待加密数据
47
+ * @param key 密钥
48
+ * @param cipherConfig 密文配置参数
49
+ * @returns 加密后数据
50
+ */
51
+ static Encrypt(context: string, key: string, cipherConfig?: CipherConfig): string;
52
+ /**
53
+ * 解密
54
+ * @param context 待解密数据
55
+ * @param key 密钥
56
+ * @param cipherConfig 配置参数
57
+ * @returns WordArray 密文参数
58
+ */
59
+ static Decrypt(context: string, key: string, cipherConfig?: CipherConfig): string;
60
+ }
61
+ /** 密文配置 */
62
+ interface CipherConfig {
63
+ /** 初始化向量(IV长度通常为16字节128位) */
64
+ iv?: string;
65
+ /** 分组密码模式 */
66
+ mode?: E_ModeType;
67
+ /** 填充策略 */
68
+ padding?: E_PaddingType;
69
+ /** 序列化格式化器 */
70
+ format?: Format;
71
+ /** 密钥派生函数 */
72
+ kdf?: KDF;
73
+ /** 用于密钥生成的盐值 */
74
+ salt?: string;
75
+ /** 用于密钥生成的哈希器 */
76
+ hasher?: new (cfg?: HasherCfg) => Hasher;
77
+ /** RC4 降值操作 */
78
+ drop?: number;
79
+ }
80
+ /** 编码转换类型 */
81
+ enum E_EncodeType {
82
+ Base64 = "base64",
83
+ Hex = "hex",
84
+ Latin1 = "latin1",
85
+ Utf16 = "utf16",
86
+ Utf16BE = "utf16BE",
87
+ Utf16LE = "utf16LE",
88
+ Utf8 = "utf8"
89
+ }
90
+ /** 加密模式类型 */
91
+ enum E_ModeType {
92
+ CBC = "cbc",
93
+ ECB = "ecb",
94
+ CFB = "cfb",
95
+ OFB = "ofb",
96
+ CTR = "ctr",
97
+ GCM = "gcm"
98
+ }
99
+ /** 填充方式类型 */
100
+ enum E_PaddingType {
101
+ PKCS7 = "pkcs7",
102
+ PKCS5 = "pkcs5",
103
+ ZeroPadding = "zeropadding",
104
+ ISO10126 = "iso10126",
105
+ ISO97971 = "iso97971",
106
+ Ansix923 = "ansix923",
107
+ NoPadding = "nopadding"
108
+ }
109
+ /** 编码转换 */
110
+ class Encode {
111
+ /**
112
+ * Base64编码
113
+ * @param data 输入数据
114
+ * @returns 编码后的字符集
115
+ */
116
+ static Base64: Encoder;
117
+ /**
118
+ * Base64url编码
119
+ * @param data 输入数据
120
+ * @returns 编码后的字符集
121
+ */
122
+ /**
123
+ * Hex编码
124
+ * @param data 输入数据
125
+ * @returns 编码后的字符集
126
+ */
127
+ static Hex: Encoder;
128
+ /**
129
+ * Latin1编码
130
+ * @param data 输入数据
131
+ * @returns 编码后的字符集
132
+ */
133
+ static Latin1: Encoder;
134
+ /**
135
+ * Utf16编码
136
+ * @param data 输入数据
137
+ * @returns 编码后的字符集
138
+ */
139
+ static Utf16: Encoder;
140
+ /**
141
+ * Utf16BE编码
142
+ * @param data 输入数据
143
+ * @returns 编码后的字符集
144
+ */
145
+ static Utf16BE: Encoder;
146
+ /**
147
+ * Utf16LE编码
148
+ * @param data 输入数据
149
+ * @returns 编码后的字符集
150
+ */
151
+ static Utf16LE: Encoder;
152
+ /**
153
+ * Utf16LE编码
154
+ * @param data 输入数据
155
+ * @returns 编码后的字符集
156
+ */
157
+ static Utf8: Encoder;
158
+ }
159
+ /**
160
+ * 格式化工具
161
+ */
162
+ class _Format {
163
+ /** Hex */
164
+ static Hex: Encoder;
165
+ }
166
+ /**
167
+ * KDF工具
168
+ */
169
+ class KDF {
170
+ }
171
+ /**
172
+ * 使用SHA256进行哈希计算
173
+ * @param message 输入数据
174
+ * @param cfg 哈希配置数据
175
+ * @returns 哈希后的值
176
+ * @example
177
+ * const hash = CryptoUtility.SHA256('message');
178
+ * const hash = CryptoUtility.SHA256(wordArray);
179
+ */
180
+ function _SHA256(message: WordArray | string, cfg?: HasherCfg): WordArray;
181
+ /**
182
+ * 使用MD5进行哈希计算
183
+ * @param message 输入数据
184
+ * @param cfg 哈希配置数据
185
+ * @returns 哈希后的值
186
+ * @example
187
+ * const hash = CryptoUtility.MD5('message');
188
+ * const hash = CryptoUtility.MD5(wordArray);
189
+ */
190
+ function _MD5(message: WordArray | string, cfg?: HasherCfg): WordArray;
191
+ /**
192
+ * HmacSHA256编码
193
+ * @param message 输入数据
194
+ * @param key 密钥
195
+ * @returns 编码后的值
196
+ * @example
197
+ * const hmac = CryptoUtility.HmacSHA256(message, key);
198
+ */
199
+ function _HmacSHA256(message: WordArray | string, key: WordArray | string): WordArray;
200
+ /**
201
+ * HmacSHA256编码
202
+ * @param message 输入数据
203
+ * @param key 密钥
204
+ * @returns 编码后的值
205
+ * @example
206
+ * const hmac = CryptoUtility.HmacMD5(message, key);
207
+ */
208
+ function _HmacMD5(message: WordArray | string, key: WordArray | string): WordArray;
209
+ /**
210
+ * 随机生成密钥
211
+ * @param length 密钥长度
212
+ * @returns 随机生成的密钥
213
+ */
214
+ function _RandomKey(length?: number): string;
215
+ }