//自定义data
var testdata={
"BucketKey":"tsadaasdsa",//参数
"FileName":"asdsadas",//参数
};
//清理
pm.globals.unset("TimeStamp");
pm.globals.unset("Sign");
pm.globals.unset("data");
//时间
var TimeStamp=parseInt(Date.parse(new Date())/1000);
//获取请求数据
var jsonObj=JSON.parse(request.data);
var AppKey=jsonObj["AppKey"];
//自定义data
var data=JSON.stringify(testdata);
//从请求获取data
//var data=JSON.stringify(jsonObj["Direction"]);
//console.log(data);
var salt="a323f9b6-1f04-420e-adb9-b06d142c5e63";
//加密前
var signValue=AppKey + TimeStamp + data + salt
console.log(signValue);
//加密
var sign=CryptoJS.MD5(signValue).toString();
console.log(sign);
//var md5Str = CryptoJS.MD5(strSign).toString();
//处理data
var reg = new RegExp( '"',"g" )
data=data.replace(reg,'\\"');
pm.globals.set("TimeStamp", TimeStamp);
pm.globals.set("Sign", sign);
pm.globals.set("data", data);
body里面的数据:
{
"AppKey":"JFFWeb",
"AppVer":"1.0.0",
"Data":"{{data}}",
"DeviceName":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36",
"DeviceType":"web",
"Lang":"CN",
"Sign":"{{Sign}}",
"TimeStamp":"{{TimeStamp}}",
"Token":"n2BKxfm96Z4YbmHqo0HUmXHFc5DefEjD3c4x0PJIFdQ=",
"Uid":100009
}