1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| var appkey = '6615be7b44ca4ab9ac03060088202792'; function createTime() { return (new Date()).valueOf(); } var time = createTime(); var method = request.method; delete request.data["sign"]; console.log("request data is : " + request.data); var keys = Object.keys(request.data), i, len = keys.length; keys.sort(); console.log("sortedKeys is : " + keys) var requestBody = ""; var firstpass = true;
for(var index in keys){ if (keys[index] == "sign") { continue; } if(!firstpass){ requestBody += "&"; } if(keys[index]=="create_time"){ request.data[keys[index]]=time; console.log(request.data[keys[index]]); } requestBody += keys[index] + "=" + request.data[keys[index]]; firstpass = false; } requestBody += '&key=' + appkey; console.log("request body is : " + requestBody);
var md5=CryptoJS.MD5(requestBody, appkey); var base64md5 = CryptoJS.enc.Base64.stringify(md5); console.log(base64md5); postman.setEnvironmentVariable('sign', base64md5);
|