添加签名计算插件

pull/236/head
13066656961 2024-07-25 19:58:04 +08:00
parent 96a7465e12
commit 0154a6cf8c
1 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,20 @@
import CryptoJS from 'crypto-js'
export default {
objectKeySort(arys) {
let newkey = Object.keys(arys).sort()
let newObj = ''
for (let i = 0; i < newkey.length; i++) {
let value = arys[newkey[i]]
if (value != null) {
newObj += [newkey[i]] + '=' + value + '&'
}
}
return newObj.substring(0, newObj.length - 1)
},
makeSign(appId, appKey, body) {
const sha1text = CryptoJS.SHA1(appKey + body + appKey).toString();
var md5HEX = CryptoJS.MD5(sha1text + appId).toString();
// console.info('本体' + body + '的签名为' + md5HEX)
return md5HEX
},
}