ms-types 0.10.7 → 0.10.9
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/package.json +2 -2
- package/types/action.d.ts +7 -2
- package/types/ai.d.ts +5 -4
- package/types/appleocr.d.ts +4 -4
- package/types/cloud.d.ts +1 -2
- package/types/config.d.ts +1 -1
- package/types/cryptoUtils.d.ts +5 -2
- package/types/device.d.ts +1 -1
- package/types/dotocr.d.ts +3 -1
- package/types/file.d.ts +2 -2
- package/types/hotUpdate.d.ts +1 -2
- package/types/http.d.ts +6 -6
- package/types/image.d.ts +1 -1
- package/types/ime.d.ts +1 -1
- package/types/logger.d.ts +2 -2
- package/types/lua/action.lua +119 -89
- package/types/lua/ai.lua +34 -16
- package/types/lua/appleocr.lua +35 -22
- package/types/lua/cloud.lua +25 -12
- package/types/lua/config.lua +18 -11
- package/types/lua/cryptoUtils.lua +35 -27
- package/types/lua/cv.lua +173 -25
- package/types/lua/device.lua +38 -20
- package/types/lua/dotocr.lua +8 -2
- package/types/lua/file.lua +61 -40
- package/types/lua/global.lua +56 -20
- package/types/lua/hid.lua +147 -101
- package/types/lua/hotupdate.lua +25 -3
- package/types/lua/http.lua +71 -41
- package/types/lua/image.lua +222 -98
- package/types/lua/ime.lua +37 -13
- package/types/lua/logger.lua +22 -12
- package/types/lua/media.lua +54 -14
- package/types/lua/mysql.lua +61 -12
- package/types/lua/netcard.lua +25 -11
- package/types/lua/node.lua +4 -2
- package/types/lua/paddleocr.lua +35 -21
- package/types/lua/pip.lua +30 -18
- package/types/lua/system.lua +112 -31
- package/types/lua/tomatoocr.lua +73 -26
- package/types/lua/tts.lua +26 -10
- package/types/lua/ui.lua +35 -14
- package/types/lua/utils.lua +27 -17
- package/types/lua/yolo.lua +25 -17
- package/types/lua/yolocls.lua +27 -18
- package/types/media.d.ts +1 -1
- package/types/mysql.d.ts +1 -1
- package/types/netCard.d.ts +3 -0
- package/types/node.d.ts +1 -1
- package/types/paddleocr.d.ts +2 -5
- package/types/pip.d.ts +3 -0
- package/types/system.d.ts +1 -1
- package/types/tomatoocr.d.ts +3 -4
- package/types/tts.d.ts +2 -2
- package/types/ui.d.ts +1 -1
- package/types/utils.d.ts +1 -1
- package/types/web.d.ts +1 -1
- package/types/yolo.d.ts +1 -1
- package/types/yoloCls.d.ts +1 -1
- package/types/zh/HID/346/250/241/345/235/227.d.ts +1 -1
- package/types/zh/HTTP/346/250/241/345/235/227.d.ts +7 -6
- package/types/zh/MySql/346/250/241/345/235/227.d.ts +2 -1
- package/types/zh/PaddleOCR/346/250/241/345/235/227.d.ts +3 -5
- package/types/zh/YOLO/345/210/206/347/261/273/346/250/241/345/235/227.d.ts +1 -1
- package/types/zh/YOLO/346/250/241/345/235/227.d.ts +1 -1
- package/types/zh//344/272/221/346/216/247/346/250/241/345/235/227.d.ts +4 -1
- package/types/zh//345/212/250/344/275/234/346/250/241/345/235/227.d.ts +7 -2
- package/types/zh//345/233/276/347/211/207/346/250/241/345/235/227.d.ts +2 -1
- package/types/zh//345/252/222/344/275/223/346/250/241/345/235/227.d.ts +1 -1
- package/types/zh//345/267/245/345/205/267/346/250/241/345/235/227.d.ts +1 -1
- package/types/zh//346/202/254/346/265/256/347/252/227/346/250/241/345/235/227.d.ts +2 -1
- package/types/zh//346/226/207/344/273/266/346/250/241/345/235/227.d.ts +3 -2
- package/types/zh//346/226/207/345/255/227/350/275/254/350/257/255/351/237/263/346/250/241/345/235/227.d.ts +3 -2
- package/types/zh//346/227/245/345/277/227/346/250/241/345/235/227.d.ts +2 -2
- package/types/zh//347/202/271/351/230/265OCR/346/250/241/345/235/227.d.ts +3 -1
- package/types/zh//347/263/273/347/273/237/346/250/241/345/235/227.d.ts +2 -1
- package/types/zh//347/272/277/347/250/213/346/250/241/345/235/227.d.ts +1 -0
- package/types/zh//350/212/202/347/202/271/346/250/241/345/235/227.d.ts +1 -1
- package/types/zh//350/213/271/346/236/234OCR.d.ts +4 -4
- package/types/zh//350/247/206/345/233/276/346/250/241/345/235/227.d.ts +2 -2
- package/types/zh//350/256/276/345/244/207/346/250/241/345/235/227.d.ts +2 -1
- package/types/zh//350/276/223/345/205/245/346/263/225/346/250/241/345/235/227.d.ts +2 -1
- package/types/zh//351/205/215/347/275/256/346/250/241/345/235/227.d.ts +1 -1
package/types/lua/ai.lua
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---@meta
|
|
2
|
+
--- AI模块
|
|
2
3
|
---@class Ai
|
|
3
4
|
local _Ai = {}
|
|
4
5
|
|
|
@@ -44,59 +45,76 @@ local _Ai = {}
|
|
|
44
45
|
|
|
45
46
|
--- 登记或更新模型供应商(脚本开头调用一次;只存内存,脚本停止即清空)
|
|
46
47
|
--- 至少要有 baseUrl、model(protocol 缺省 openai);同 id 再次调用为更新,没传的字段沿用旧值
|
|
47
|
-
---@param config table
|
|
48
|
-
---@return AiProvider|nil
|
|
48
|
+
---@param config table 新建至少要有 baseUrl、model(protocol 缺省 openai);同 id 再次调用为更新,没传的字段沿用旧值
|
|
49
|
+
---@return AiProvider|nil 保存后的完整配置;protocol 不合法或缺 baseUrl / model 时返回 null
|
|
50
|
+
---@example ai.setProvider({ name = "DeepSeek", protocol = "openai", baseUrl = "https://api.deepseek.com", apiKey = "sk-...", model = "deepseek-v4-flash" })
|
|
49
51
|
function _Ai.setProvider(config) return nil end
|
|
50
52
|
|
|
51
53
|
--- 列出已登记的供应商,默认项排在最前
|
|
52
54
|
---@return AiProvider[]
|
|
55
|
+
---@example for _, p in ipairs(ai.getProviders()) do
|
|
56
|
+
--- logi(p.name)
|
|
57
|
+
--- end
|
|
53
58
|
function _Ai.getProviders() return {} end
|
|
54
59
|
|
|
55
60
|
--- 获取默认供应商;一个都没登记时返回 nil
|
|
56
|
-
---@return AiProvider|nil
|
|
61
|
+
---@return AiProvider|nil 一个都没登记时返回 null
|
|
62
|
+
---@example local p = ai.getDefaultProvider()
|
|
57
63
|
function _Ai.getDefaultProvider() return nil end
|
|
58
64
|
|
|
59
65
|
--- 切换默认供应商
|
|
60
66
|
---@param id string 供应商 id 或 name
|
|
61
67
|
---@return boolean id 或 name 存在返回 true
|
|
68
|
+
---@example ai.setDefaultProvider("cheap")
|
|
62
69
|
function _Ai.setDefaultProvider(id) return true end
|
|
63
70
|
|
|
64
71
|
--- 删除供应商;删掉的是默认项时默认转给剩下的第一个
|
|
65
72
|
---@param id string 供应商 id 或 name
|
|
66
73
|
---@return boolean 存在并删除返回 true
|
|
74
|
+
---@example ai.removeProvider("cheap")
|
|
67
75
|
function _Ai.removeProvider(id) return true end
|
|
68
76
|
|
|
69
77
|
--- 单轮提问,可附带图片;图片参数与 image 模块一致(image + x/y/ex/ey,或 images)
|
|
70
|
-
---@param prompt string
|
|
71
|
-
---@param options AiOptions|nil
|
|
72
|
-
---@return string|nil 回复文本;失败返回
|
|
78
|
+
---@param prompt string 问题
|
|
79
|
+
---@param options AiOptions|nil 可选参数,图片参数与 image 模块一致:image 为 imageId,x/y/ex/ey 同 image.clip 裁剪
|
|
80
|
+
---@return string|nil 回复文本;失败返回 null
|
|
81
|
+
---@example ai.ask("屏幕上有几个按钮?", { image = "screen" })
|
|
82
|
+
--- ai.ask("这个区域的价格是多少?", { image = "screen", x = 0, y = 300, ex = 750, ey = 500 })
|
|
73
83
|
function _Ai.ask(prompt, options) return nil end
|
|
74
84
|
|
|
75
85
|
--- 是非判断:让模型只回答 yes / no
|
|
76
|
-
---@param question string
|
|
77
|
-
---@param options AiOptions|nil
|
|
86
|
+
---@param question string 要判断的问题
|
|
87
|
+
---@param options AiOptions|nil 同 ask
|
|
78
88
|
---@return boolean 肯定为 true;否定或请求失败为 false(失败时 lastError() 有内容)
|
|
89
|
+
---@example if ai.judge("是否出现了「领取成功」?", { image = "screen" }) then
|
|
90
|
+
--- ...
|
|
91
|
+
--- end
|
|
79
92
|
function _Ai.judge(question, options) return false end
|
|
80
93
|
|
|
81
94
|
--- 结构化提取:要求模型输出 JSON 并解析成表
|
|
82
|
-
---@param prompt string
|
|
83
|
-
---@param options AiOptions|nil
|
|
84
|
-
---@return table|nil
|
|
95
|
+
---@param prompt string 提取要求
|
|
96
|
+
---@param options AiOptions|nil 同 ask,另支持 schema
|
|
97
|
+
---@return table|nil 解析后的对象或数组;没有合法 JSON 或请求失败返回 null
|
|
98
|
+
---@example local d = ai.extract("提取验证码", { image = "screen", x = 100, y = 800, ex = 600, ey = 900, schema = { code = "string" } })
|
|
99
|
+
--- if d then logi(d.code) end
|
|
85
100
|
function _Ai.extract(prompt, options) return nil end
|
|
86
101
|
|
|
87
102
|
--- 多轮对话:自己维护完整消息数组,每次整表传入。失败返回 nil,不要把空回复推进历史。
|
|
88
|
-
---@param messages (AiMessage|string)[]
|
|
103
|
+
---@param messages (AiMessage|string)[] 消息数组;直接写字符串等于 user 消息;图片写在该条消息上
|
|
89
104
|
---@param options AiOptions|nil provider / model / temperature / maxTokens / json / timeout(不用 system / image)
|
|
90
|
-
---@return string|nil 回复文本;失败返回
|
|
105
|
+
---@return string|nil 回复文本;失败返回 null
|
|
106
|
+
---@example ai.chat({ { role = "system", content = "你是助手" }, { role = "user", content = "看下这是哪个页面", image = "screen" } })
|
|
91
107
|
function _Ai.chat(messages, options) return nil end
|
|
92
108
|
|
|
93
109
|
--- 从模型文本里解析 JSON,自动剥掉 Markdown 代码块和前后解释
|
|
94
|
-
---@param text string
|
|
95
|
-
---@return table|nil
|
|
110
|
+
---@param text string 模型输出
|
|
111
|
+
---@return table|nil 解析结果;失败返回 null
|
|
112
|
+
---@example ai.parseJson("```json\n{\"a\":1}\n```")
|
|
96
113
|
function _Ai.parseJson(text) return nil end
|
|
97
114
|
|
|
98
115
|
--- 最近一次调用失败的原因;上一次调用成功时返回 nil
|
|
99
|
-
---@return string|nil
|
|
116
|
+
---@return string|nil 错误文案;上一次调用成功时返回 null
|
|
117
|
+
---@example if ai.ask("你好") == nil then loge(ai.lastError()) end
|
|
100
118
|
function _Ai.lastError() return nil end
|
|
101
119
|
|
|
102
120
|
---@type Ai
|
package/types/lua/appleocr.lua
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---@meta
|
|
2
|
+
--- AppleOCR模块
|
|
2
3
|
---@class AppleOCR
|
|
3
4
|
local _AppleOCR = {}
|
|
4
5
|
|
|
@@ -15,13 +16,17 @@ local _AppleOCR = {}
|
|
|
15
16
|
---@field centerY integer 文本区域中心点 y 坐标
|
|
16
17
|
|
|
17
18
|
--- 识别文本,坐标映射为原图/全屏绝对坐标
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
---@param input string 输入源(imageId、URL字符串、文件路径或"screen","screen"表示使用当前屏幕)
|
|
20
|
+
---@param x integer|nil 边界框左上角x坐标 默认 0
|
|
21
|
+
---@param y integer|nil 边界框左上角y坐标 默认 0
|
|
22
|
+
---@param ex integer|nil 边界框右下角x坐标 默认 0
|
|
23
|
+
---@param ey integer|nil 边界框右下角y坐标 默认 0
|
|
24
|
+
---@param langs string[]|nil 识别语言数组,默认为["zh-Hans", "en-US"]
|
|
25
|
+
---@return AppleOCRResult[] 识别结果数组,坐标为原图/全屏绝对坐标
|
|
26
|
+
---@example local results = appleocr.recognizeAbs("screen", 100, 100, 500, 300)
|
|
27
|
+
--- if #results > 0 then
|
|
28
|
+
--- action.click(results[0].centerX, results[0].centerY)
|
|
29
|
+
--- end
|
|
25
30
|
function _AppleOCR.recognizeAbs(input, x, y, ex, ey, langs)
|
|
26
31
|
---@type AppleOCRResult[]
|
|
27
32
|
local ret = {}
|
|
@@ -29,12 +34,16 @@ function _AppleOCR.recognizeAbs(input, x, y, ex, ey, langs)
|
|
|
29
34
|
end
|
|
30
35
|
|
|
31
36
|
--- 识别数字,坐标映射为原图/全屏绝对坐标
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
---@param input string 输入源(imageId、URL字符串、文件路径或"screen","screen"表示使用当前屏幕)
|
|
38
|
+
---@param x integer|nil 边界框左上角x坐标
|
|
39
|
+
---@param y integer|nil 边界框左上角y坐标
|
|
40
|
+
---@param ex integer|nil 边界框右下角x坐标
|
|
41
|
+
---@param ey integer|nil 边界框右下角y坐标
|
|
42
|
+
---@return AppleOCRResult[] 识别结果数组,坐标为原图/全屏绝对坐标
|
|
43
|
+
---@example local results = appleocr.recognizeNumbersAbs("screen", 100, 100, 500, 300)
|
|
44
|
+
--- if #results > 0 then
|
|
45
|
+
--- action.click(results[0].centerX, results[0].centerY)
|
|
46
|
+
--- end
|
|
38
47
|
function _AppleOCR.recognizeNumbersAbs(input, x, y, ex, ey)
|
|
39
48
|
---@type AppleOCRResult[]
|
|
40
49
|
local ret = {}
|
|
@@ -42,15 +51,19 @@ function _AppleOCR.recognizeNumbersAbs(input, x, y, ex, ey)
|
|
|
42
51
|
end
|
|
43
52
|
|
|
44
53
|
--- 查找文本,坐标映射为原图/全屏绝对坐标
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
---@param input string 输入源(imageId、URL字符串、文件路径或"screen","screen"表示使用当前屏幕)
|
|
55
|
+
---@param targets string[]|string 要查找的目标文本数组,可匹配识别结果中的子串
|
|
56
|
+
---@param x integer|nil 边界框左上角x坐标
|
|
57
|
+
---@param y integer|nil 边界框左上角y坐标
|
|
58
|
+
---@param ex integer|nil 边界框右下角x坐标
|
|
59
|
+
---@param ey integer|nil 边界框右下角y坐标
|
|
60
|
+
---@param langs string[]|nil 识别语言数组,默认为["zh-Hans", "en-US"]
|
|
61
|
+
---@param exactMatch boolean|nil 是否完整匹配,默认 false 表示包含匹配;传 true 时要求整条 OCR 识别结果文本等于目标文本
|
|
62
|
+
---@return AppleOCRResult[] 命中子串的识别结果数组,坐标为原图/全屏绝对坐标
|
|
63
|
+
---@example local results = appleocr.findTextAbs("screen", {"开始"}, 100, 100, 500, 400)
|
|
64
|
+
--- if #results > 0 then
|
|
65
|
+
--- action.click(results[0].centerX, results[0].centerY)
|
|
66
|
+
--- end
|
|
54
67
|
function _AppleOCR.findTextAbs(input, targets, x, y, ex, ey, langs, exactMatch)
|
|
55
68
|
---@type AppleOCRResult[]
|
|
56
69
|
local ret = {}
|
package/types/lua/cloud.lua
CHANGED
|
@@ -1,31 +1,44 @@
|
|
|
1
1
|
---@meta
|
|
2
|
+
--- 云控模块
|
|
2
3
|
---@class Cloud
|
|
3
4
|
local _Cloud = {}
|
|
4
5
|
|
|
5
6
|
--- 云控 WebSocket;仅主脚本注册 onEvent
|
|
6
7
|
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
---@param
|
|
10
|
-
---@
|
|
8
|
+
--- 连接云控服务器。
|
|
9
|
+
--- 只能在主脚本上下文调用;只影响当前运行期云控连接,不会写入设置页的持久化云控配置。
|
|
10
|
+
---@param url string 完整 ws:// 或 wss:// 云控地址。
|
|
11
|
+
---@param deviceNo string|nil 可选设备编号,不传时沿用当前保存的设备编号。
|
|
12
|
+
---@return boolean URL 校验通过且连接请求已提交时返回 true。
|
|
13
|
+
---@example local accepted = cloud.connect("wss://example.com/control", "device-001")
|
|
11
14
|
function _Cloud.connect(url, deviceNo) return false end
|
|
12
15
|
|
|
13
|
-
---
|
|
14
|
-
---@return boolean
|
|
16
|
+
--- 判断云控是否已经连接成功。
|
|
17
|
+
---@return boolean 已连接时返回 true。
|
|
18
|
+
---@example if cloud.isConnected() then
|
|
19
|
+
--- cloud.report("status", { value = "ready" })
|
|
20
|
+
--- end
|
|
15
21
|
function _Cloud.isConnected() return false end
|
|
16
22
|
|
|
17
23
|
--- disconnect
|
|
18
24
|
|
|
25
|
+
--- 断开云控连接并停止自动重连。
|
|
26
|
+
---@example cloud.disconnect()
|
|
19
27
|
function _Cloud.disconnect() end
|
|
20
28
|
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
---@param
|
|
24
|
-
---@
|
|
29
|
+
--- 上报普通 Object 到云控服务器。
|
|
30
|
+
--- 设备总览状态固定使用 cloud.report("cloud:status", data) 上报;data 的 key 必须是云控端已配置的自定义字段名,多余字段不会在设备总览显示。
|
|
31
|
+
---@param event string 自定义事件名称。
|
|
32
|
+
---@param data table<string, any> 可 JSON 序列化的普通 Object。
|
|
33
|
+
---@return boolean 已连接且数据可写出时返回 true。
|
|
34
|
+
---@example cloud.report("done", { value = 1 })
|
|
25
35
|
function _Cloud.report(event, data) return false end
|
|
26
36
|
|
|
27
|
-
---
|
|
28
|
-
---@param callback fun(event: string, data: table<string, any>)|nil
|
|
37
|
+
--- 监听服务端下发的 scriptEvent 事件(仅主线程调用,不能在线程脚本中调用)。
|
|
38
|
+
---@param callback fun(event: string, data: table<string, any>)|nil 主脚本回调函数;传入 null 可取消监听。
|
|
39
|
+
---@example cloud.onEvent(function(event, data)
|
|
40
|
+
--- logi("server event:", event, data)
|
|
41
|
+
--- end)
|
|
29
42
|
function _Cloud.onEvent(callback) end
|
|
30
43
|
|
|
31
44
|
---@type Cloud
|
package/types/lua/config.lua
CHANGED
|
@@ -1,34 +1,41 @@
|
|
|
1
1
|
---@meta
|
|
2
|
+
--- 配置模块
|
|
2
3
|
---@class Config
|
|
3
4
|
local _Config = {}
|
|
4
5
|
|
|
5
6
|
--- 获取所有配置
|
|
6
|
-
---@return table<string, any>
|
|
7
|
+
---@return table<string, any> 所有配置
|
|
8
|
+
---@example config.all()
|
|
7
9
|
function _Config.all() return {} end
|
|
8
10
|
|
|
9
11
|
--- 用完整表覆盖配置
|
|
10
|
-
---@param config table<string, any>
|
|
11
|
-
---@return boolean
|
|
12
|
+
---@param config table<string, any> 包含所有配置项的字典
|
|
13
|
+
---@return boolean 如果设置成功返回true,否则返回false
|
|
14
|
+
---@example config.setAll({ key = 100 })
|
|
12
15
|
function _Config.setAll(config) return true end
|
|
13
16
|
|
|
14
17
|
--- 设置单个配置
|
|
15
|
-
---@param key string
|
|
16
|
-
---@param value any
|
|
17
|
-
---@return boolean
|
|
18
|
+
---@param key string 配置key
|
|
19
|
+
---@param value any 配置值
|
|
20
|
+
---@return boolean 设置是否成功
|
|
21
|
+
---@example config.set("key", 100)
|
|
18
22
|
function _Config.set(key, value) return true end
|
|
19
23
|
|
|
20
24
|
--- 读取配置
|
|
21
|
-
---@param key string
|
|
22
|
-
---@return any|nil
|
|
25
|
+
---@param key string 配置key
|
|
26
|
+
---@return any|nil 配置值
|
|
27
|
+
---@example config.get("key")
|
|
23
28
|
function _Config.get(key) return nil end
|
|
24
29
|
|
|
25
30
|
--- 获取 KUI_CONFIG 表;不存在时返回空表
|
|
26
|
-
---@return table<string, any>
|
|
31
|
+
---@return table<string, any> KUI_CONFIG 对应的字典,配置不存在或无法转换时返回空对象
|
|
32
|
+
---@example config.getKuiConfig()
|
|
27
33
|
function _Config.getKuiConfig() return {} end
|
|
28
34
|
|
|
29
35
|
--- 删除配置
|
|
30
|
-
---@param key string
|
|
31
|
-
---@return boolean
|
|
36
|
+
---@param key string 配置key
|
|
37
|
+
---@return boolean 删除是否成功
|
|
38
|
+
---@example config.remove("key")
|
|
32
39
|
function _Config.remove(key) return true end
|
|
33
40
|
|
|
34
41
|
---@type Config
|
|
@@ -1,46 +1,54 @@
|
|
|
1
1
|
---@meta
|
|
2
|
+
--- 加密工具模块
|
|
2
3
|
---@class CryptoUtils
|
|
3
4
|
local _CryptoUtils = {}
|
|
4
5
|
|
|
5
|
-
---
|
|
6
|
-
---@param data string
|
|
7
|
-
---@param aesKey string
|
|
8
|
-
---@param noPadding boolean
|
|
9
|
-
---@return string
|
|
6
|
+
--- 使用AES ECB模式加密数据 默认使用PKCS7填充
|
|
7
|
+
---@param data string 要加密的数据
|
|
8
|
+
---@param aesKey string AES密钥 支持16位、24位、32位字符串
|
|
9
|
+
---@param noPadding boolean 是否禁用填充,默认为false, 默认使用PKCS7填充
|
|
10
|
+
---@return string 加密后的数据
|
|
11
|
+
---@example cryptoUtils.encryptWithAES_ECB(data, aesKey, noPadding)
|
|
10
12
|
function _CryptoUtils.encryptWithAES_ECB(data, aesKey, noPadding) return "" end
|
|
11
13
|
|
|
12
|
-
---
|
|
13
|
-
---@param data string
|
|
14
|
-
---@param aesKey string
|
|
15
|
-
---@param noPadding boolean
|
|
16
|
-
---@return string
|
|
14
|
+
--- 使用AES ECB模式解密数据 默认使用PKCS7填充
|
|
15
|
+
---@param data string 要解密的数据
|
|
16
|
+
---@param aesKey string AES密钥 支持16位、24位、32位字符串
|
|
17
|
+
---@param noPadding boolean 是否禁用填充,默认为false, 默认使用PKCS7填充
|
|
18
|
+
---@return string 解密后的数据
|
|
19
|
+
---@example cryptoUtils.decryptWithAES_ECB(data, aesKey, noPadding)
|
|
17
20
|
function _CryptoUtils.decryptWithAES_ECB(data, aesKey, noPadding) return "" end
|
|
18
21
|
|
|
19
|
-
---
|
|
20
|
-
---@param data string
|
|
21
|
-
---@param publicKeyBase64 string
|
|
22
|
-
---@return string
|
|
22
|
+
--- 使用RSA公钥加密数据 默认使用PKCS1填充
|
|
23
|
+
---@param data string 要加密的数据
|
|
24
|
+
---@param publicKeyBase64 string RSA公钥
|
|
25
|
+
---@return string 加密后的数据
|
|
26
|
+
---@example cryptoUtils.encryptWithRSA(data, publicKeyBase64)
|
|
23
27
|
function _CryptoUtils.encryptWithRSA(data, publicKeyBase64) return "" end
|
|
24
28
|
|
|
25
|
-
---
|
|
26
|
-
---@param encryptedData string
|
|
27
|
-
---@param privateKeyBase64 string
|
|
28
|
-
---@return string
|
|
29
|
+
--- 使用RSA私钥解密数据 默认使用PKCS1填充
|
|
30
|
+
---@param encryptedData string 要解密的数据
|
|
31
|
+
---@param privateKeyBase64 string RSA私钥
|
|
32
|
+
---@return string 解密后的数据
|
|
33
|
+
---@example cryptoUtils.decryptWithRSA(encryptedData, privateKeyBase64)
|
|
29
34
|
function _CryptoUtils.decryptWithRSA(encryptedData, privateKeyBase64) return "" end
|
|
30
35
|
|
|
31
|
-
---
|
|
32
|
-
---@param data string
|
|
33
|
-
---@return string
|
|
36
|
+
--- 计算MD5值
|
|
37
|
+
---@param data string 要计算MD5的值
|
|
38
|
+
---@return string MD5值
|
|
39
|
+
---@example cryptoUtils.md5(data)
|
|
34
40
|
function _CryptoUtils.md5(data) return "" end
|
|
35
41
|
|
|
36
|
-
---
|
|
37
|
-
---@param data string
|
|
38
|
-
---@return string
|
|
42
|
+
--- 计算SHA1值
|
|
43
|
+
---@param data string 要计算SHA1的值
|
|
44
|
+
---@return string SHA1值
|
|
45
|
+
---@example cryptoUtils.sha1(data)
|
|
39
46
|
function _CryptoUtils.sha1(data) return "" end
|
|
40
47
|
|
|
41
|
-
---
|
|
42
|
-
---@param data string
|
|
43
|
-
---@return string
|
|
48
|
+
--- 计算SHA256值
|
|
49
|
+
---@param data string 要计算SHA256的值
|
|
50
|
+
---@return string SHA256值
|
|
51
|
+
---@example cryptoUtils.sha256(data)
|
|
44
52
|
function _CryptoUtils.sha256(data) return "" end
|
|
45
53
|
|
|
46
54
|
---@type CryptoUtils
|