标签:mem 数据 enc create first valueof val 排序 acs
// 服务器地址 var server = ‘XXXXXXXXXXXX‘; //秘钥Key var secretKey = ‘XXXXXXXXXXXX‘; //获取当前时间 function createTime() { return (new Date()).valueOf(); } // 当前时间 var time = createTime(); //提交方式 var method = request.method; // 获取post请求的参数 var param = request.data; // 获取get请求的参数 var queryParam = pm.request.url.query.members; for (var i in queryParam) { if (queryParam[i].key == "Signature") { continue; } param[queryParam[i].key] = queryParam[i].value; } var keys = Object.keys(param), i, len = keys.length; keys.sort();//根据key经行排序 var requestBody = ""; var firstpass = true; // 构造数据为 key=param&key=param....字符串 for(var index in keys){ if(!firstpass){ requestBody += "&"; } if(keys[index]=="create_time"){ param[keys[index]]=time; console.log(param[keys[index]]); } requestBody += keys[index] + "=" + param[keys[index]]; firstpass = false; } var encodeURIdataServer = server+"?"+requestBody; // postman.setEnvironmentVariable(‘encodeURIdataServer‘, encodeURIdataServer); //sha1加密 var Signature = CryptoJS.HmacSHA1(encodeURIdataServer,secretKey); // HMAC计算返回原始二进制数据后进行Base64编码 var base64Signature = CryptoJS.enc.Base64.stringify(Signature); postman.setEnvironmentVariable(‘Signature‘, encodeURIComponent(base64Signature));
标签:mem 数据 enc create first valueof val 排序 acs
原文地址:https://www.cnblogs.com/ChineseLiao/p/10257079.html