#pre-request-script
1
postman.setGlobalVariable(“time”,Math.round(new Date().getTime()));
time = postman.getGlobalVariable(‘time’);
signKey = “aaaa”;
//字符串进行md5加密
str = signKey+time;
strmd5= CryptoJS.MD5(str).toString();
console.log(strmd5);
// 加密 写法2
var base64Md5Str = CryptoJS.enc.Utf8.parse(strmd5).toString(CryptoJS.enc.Base64);
console.log(base64Md5Str)
postman.setGlobalVariable(“sign”,base64Md5Str);
2
postman.setGlobalVariable(“userkey”,“aa”);
userkey = postman.getGlobalVariable(‘userkey’);
postman.setGlobalVariable(“nonce”,Math.random() * 1000000);
nonce = postman.getGlobalVariable(‘nonce’);
postman.setGlobalVariable(“timestamp”,Math.round(new Date().getTime()));
timestamp = postman.getGlobalVariable(‘timestamp’);
signKey = “aa”;
secret = “aa”;
//字符串进行md5加密
str = userkey+nonce+secret+timestamp;
signature= CryptoJS.MD5(str).toString();
signature= CryptoJS.MD5(signature).toString();
signature= CryptoJS.MD5(signature).toString();
postman.setGlobalVariable(“signature”,signature.toUpperCase());