共计 1263 个字符,预计需要花费 4 分钟才能阅读完成。
var username = "zyz3";
var securityKey = "111111111";
var timestamp = new Date().getTime();
var paraStr = username+securityKey+timestamp;
var accesstoken = CryptoJS.MD5(paraStr).toString();
postman.setGlobalVariable("username",username)
postman.setGlobalVariable("timestamp",timestamp)
postman.setGlobalVariable("accesstoken",accesstoken)
其余实现:
var moment = require('moment');
// AES 加密办法
// word 是加密内容,keyStr 是秘钥
// ECB:加密算法,padding:对齐形式
// ciphertext:16 进制加密,不加此办法就是 Base64 加密
function encrypt(word, keyStr){var key = CryptoJS.enc.Utf8.parse(keyStr);
var srcs = CryptoJS.enc.Utf8.parse(word);
console.log('content:'+word);
var encrypted = CryptoJS.AES.encrypt(srcs, key, {mode:CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7});
return encrypted.toString();}
var curDate = new Date();
var aesSecret="";
var appid = "";
var appSecret = "";
var date1 = moment().format("YYYYMMDD");
var date2 = moment().format("YYYYMMDDHHmmss");
var data = [];
var datajson = JSON.stringify(data);
var data1 = encrypt(datajson,aesSecret);
var sign1 = appid+appSecret+date1+data1;
var token = CryptoJS.MD5(sign1).toString();
var tranId = date2+appid;
var serviceId = "";
postman.setGlobalVariable("token",token)
postman.setGlobalVariable("tranId",tranId)
postman.setGlobalVariable("serviceId",serviceId)
postman.setGlobalVariable("serviceValue",serviceId)
postman.setGlobalVariable("datajson",datajson)
正文完
发表至: javascript
2022-04-15