1. 使用内置的全局变量{{$timestamp}},秒级时间戳
2. 在pre-request script中编写js代码
pm.environment.set('now', Math.round(new Date/1000)); # 秒级时间戳
pm.environment.set(‘milliTimestamp’, Date.now().toString()); # 当前时间,毫秒级时间戳
3. MD5加密
//获取当前时间戳
var time = Math.round(new Date/1000);
pm.environment.set('time', time);
console.log(time)
//md5加密
var content = "content={\"deviceIdList\":[\"1104a8979207a19qwq1\"],\"pageIndex\":1,\"pageSize\":10,\"pid\":\"test\"}&0017b1b52a3179e625af935b"+time+"qw1997";
console.log(content)
var sign = CryptoJS.MD5(content).toString();
pm.environment.set("sign", sign);
console.log(sign)
-
效果同MD5加密工具