😎增加 API数据签名
This commit is contained in:
parent
3ea848ea65
commit
18e076befa
@ -2,7 +2,7 @@
|
|||||||
"name": "admin.net.pro",
|
"name": "admin.net.pro",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "2.4.33",
|
"version": "2.4.33",
|
||||||
"lastBuildTime": "2024.10.17",
|
"lastBuildTime": "2024.10.18",
|
||||||
"description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",
|
"description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",
|
||||||
"author": "zuohuaijun",
|
"author": "zuohuaijun",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -29,12 +29,13 @@
|
|||||||
"axios": "^1.7.7",
|
"axios": "^1.7.7",
|
||||||
"countup.js": "^2.8.0",
|
"countup.js": "^2.8.0",
|
||||||
"cropperjs": "^1.6.2",
|
"cropperjs": "^1.6.2",
|
||||||
|
"crypto-js": "^4.2.0",
|
||||||
"echarts": "^5.5.1",
|
"echarts": "^5.5.1",
|
||||||
"echarts-gl": "^2.0.9",
|
"echarts-gl": "^2.0.9",
|
||||||
"echarts-wordcloud": "^2.1.0",
|
"echarts-wordcloud": "^2.1.0",
|
||||||
"element-plus": "^2.8.5",
|
"element-plus": "^2.8.5",
|
||||||
"exceljs": "^4.4.0",
|
"exceljs": "^4.4.0",
|
||||||
"ezuikit-js": "^8.0.12",
|
"ezuikit-js": "^8.0.13-alpha.2",
|
||||||
"gcoord": "^1.0.6",
|
"gcoord": "^1.0.6",
|
||||||
"js-cookie": "^3.0.5",
|
"js-cookie": "^3.0.5",
|
||||||
"js-table2excel": "^1.1.2",
|
"js-table2excel": "^1.1.2",
|
||||||
@ -62,7 +63,7 @@
|
|||||||
"vue": "^3.5.12",
|
"vue": "^3.5.12",
|
||||||
"vue-clipboard3": "^2.0.0",
|
"vue-clipboard3": "^2.0.0",
|
||||||
"vue-demi": "0.14.6",
|
"vue-demi": "0.14.6",
|
||||||
"vue-draggable-plus": "^0.5.3",
|
"vue-draggable-plus": "^0.5.4",
|
||||||
"vue-grid-layout": "3.0.0-beta1",
|
"vue-grid-layout": "3.0.0-beta1",
|
||||||
"vue-i18n": "^10.0.4",
|
"vue-i18n": "^10.0.4",
|
||||||
"vue-json-pretty": "^2.4.0",
|
"vue-json-pretty": "^2.4.0",
|
||||||
@ -70,7 +71,7 @@
|
|||||||
"vue-router": "^4.4.5",
|
"vue-router": "^4.4.5",
|
||||||
"vue-signature-pad": "^3.0.2",
|
"vue-signature-pad": "^3.0.2",
|
||||||
"vue3-tree-org": "^4.2.2",
|
"vue3-tree-org": "^4.2.2",
|
||||||
"vxe-pc-ui": "^4.2.21",
|
"vxe-pc-ui": "^4.2.23",
|
||||||
"vxe-table": "^4.7.59",
|
"vxe-table": "^4.7.59",
|
||||||
"vxe-table-plugin-element": "^4.0.4",
|
"vxe-table-plugin-element": "^4.0.4",
|
||||||
"vxe-table-plugin-export-xlsx": "^4.0.7",
|
"vxe-table-plugin-export-xlsx": "^4.0.7",
|
||||||
@ -84,8 +85,8 @@
|
|||||||
"@types/node": "^20.16.5",
|
"@types/node": "^20.16.5",
|
||||||
"@types/nprogress": "^0.2.3",
|
"@types/nprogress": "^0.2.3",
|
||||||
"@types/sortablejs": "^1.15.8",
|
"@types/sortablejs": "^1.15.8",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.9.0",
|
"@typescript-eslint/eslint-plugin": "^8.10.0",
|
||||||
"@typescript-eslint/parser": "^8.9.0",
|
"@typescript-eslint/parser": "^8.10.0",
|
||||||
"@vitejs/plugin-vue": "^5.1.4",
|
"@vitejs/plugin-vue": "^5.1.4",
|
||||||
"@vitejs/plugin-vue-jsx": "^4.0.1",
|
"@vitejs/plugin-vue-jsx": "^4.0.1",
|
||||||
"@vue/compiler-sfc": "^3.5.12",
|
"@vue/compiler-sfc": "^3.5.12",
|
||||||
@ -96,7 +97,7 @@
|
|||||||
"less": "^4.2.0",
|
"less": "^4.2.0",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
"rollup-plugin-visualizer": "^5.12.0",
|
"rollup-plugin-visualizer": "^5.12.0",
|
||||||
"sass": "^1.80.1",
|
"sass": "^1.80.2",
|
||||||
"terser": "^5.36.0",
|
"terser": "^5.36.0",
|
||||||
"typescript": "^5.6.3",
|
"typescript": "^5.6.3",
|
||||||
"vite": "^5.4.9",
|
"vite": "^5.4.9",
|
||||||
|
|||||||
1
Web/src/types/global.d.ts
vendored
1
Web/src/types/global.d.ts
vendored
@ -12,6 +12,7 @@ declare module 'vcrontab-3';
|
|||||||
declare module 'vue-signature-pad';
|
declare module 'vue-signature-pad';
|
||||||
declare module 'vform3-builds';
|
declare module 'vform3-builds';
|
||||||
declare module 'jwchat';
|
declare module 'jwchat';
|
||||||
|
declare module 'crypto-js'
|
||||||
|
|
||||||
// 声明一个模块,防止引入文件时报错
|
// 声明一个模块,防止引入文件时报错
|
||||||
declare module '*.json';
|
declare module '*.json';
|
||||||
|
|||||||
58
Web/src/utils/data-signature.ts
Normal file
58
Web/src/utils/data-signature.ts
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import CryptoJS from 'crypto-js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成 KSort 签名
|
||||||
|
* @param appId APP_ID
|
||||||
|
* @param appKey APP_KEY
|
||||||
|
* @param command 命令
|
||||||
|
* @param data 数据
|
||||||
|
* @param timestamp 时间戳(可选)
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function signatureByKSort(appId: string, appKey: string, command: string, data: any, timestamp: number | null = null) {
|
||||||
|
// 序列化数据
|
||||||
|
const input = typeof data === 'string' ? (data as string) : JSON.stringify(data);
|
||||||
|
|
||||||
|
// 生成时间戳
|
||||||
|
if (!timestamp) {
|
||||||
|
timestamp = new Date().getTime() - new Date('1970-01-01T00:00:00Z').getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
const sData: any = {
|
||||||
|
app_id: appId,
|
||||||
|
app_key: appKey,
|
||||||
|
command,
|
||||||
|
data: input,
|
||||||
|
timestamp,
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取对象的所有键并对键进行排序
|
||||||
|
const keys = Object.keys(sData);
|
||||||
|
keys.sort();
|
||||||
|
|
||||||
|
// 生成签名
|
||||||
|
let result = '';
|
||||||
|
for (let i = 0; i < keys.length; i++) {
|
||||||
|
const key = keys[i];
|
||||||
|
const value = sData[key];
|
||||||
|
result += key + '=' + value;
|
||||||
|
|
||||||
|
if (i < keys.length - 1) {
|
||||||
|
result += ',';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MD5 小写加密
|
||||||
|
const hash = CryptoJS.MD5(result);
|
||||||
|
const hexString = hash.toString(CryptoJS.enc.Hex);
|
||||||
|
var signature = hexString.toLowerCase();
|
||||||
|
|
||||||
|
return {
|
||||||
|
app_id: appId,
|
||||||
|
app_key: appKey,
|
||||||
|
command,
|
||||||
|
data: input,
|
||||||
|
timestamp,
|
||||||
|
signature,
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user