猿问

js如何实现sign算法验证?

参数:
url: https://uhome.haier.net:6503/css/v1/protected/familyService/family
appKey: e8a1e19058c0928d7690cfd59c6b062d
appId: SV-ABC-0000
serviceKey: e8a1e19058c092fdfd328dd59c6b062d
serviceId: UWS-FML-0000
timestamp: 1234567890
Body:
{
"userId":"u12",
"deviceType":"101c120024000810e2010540000044"
}

待签名字符串:
/css/v1/protected/familyService/family{"userId":"u12","deviceType":"101c120024000810e2010540000044"}SV-ABC-0000e8a1e19058c0928d7690cfd59c6b062d

签名字符串:
7c2e0ff62383263f10179d614c5a92df

给定的参数如何用JS 拼接成待签名字符串
主要是几个参数拼接,求JS 方法如何拼接成

/css/v1/protected/familyService/family{"userId":"u12","deviceType":"101c120024000810e2010540000044"}SV-ABC-0000e8a1e19058c0928d7690cfd59c6b062d

最后字符串如何转换成签名字符串 sign=SHA256(url字符串 + Body字符串+appId+appKey +timestamp);

https://img4.mukewang.com/5c6ce17e0001623804540023.jpg

MMTTMM
浏览 1470回答 1
1回答

RISEBY

//封装全局签名函数Vue.prototype.signGenerate = (obj, key) => {  let str0 = '';  for (let i in obj) {    if (i != 'sign') {      let str1 = '';      str1 = i + '=' + obj[i];      str0 += str1;    }  }  return sha1(str0 + key);};//调用let obj = {              appid: '',              terminalNumber: '',              time: parseInt(new Date().getTime() / 1000)           };obj.sign = this.signGenerate(obj, this.key);
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答