动态计算 md5 header字段

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
var CryptoJS = require("crypto-js");

// Unix 时间秒数
var nowSec = Math.floor(new Date().getTime()/1000);

// 获取 collection 变量
var appID = pm.collectionVariables.get("TAGAppID");
var random = pm.collectionVariables.get("TAGRandom");

// 计算MD5
var hash = CryptoJS.MD5(appID +"token" + nowSec + random ).toString();

// Set the new collection variable
pm.collectionVariables.set("timestampS", nowSec);
pm.collectionVariables.set("TAGToken", hash);