· 4 years ago · Dec 02, 2020, 02:24 AM
1const secretKey = "<YOUR_SECRET_KEY>";
2console.log("secretKey:" + secretKey);
3
4var timestamp = (new Date).getTime();;
5console.log("timestamp:" + timestamp);
6
7pm.request.headers.add({
8 key: "x-api-timestamp",
9 value: timestamp
10});
11
12var body = JSON.stringify(JSON.parse(pm.request.body.raw));
13var dataToSign = timestamp + body;
14console.log("dataToSign:" + dataToSign);
15
16var signature = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(dataToSign, secretKey));
17console.log("signature:" + signature);
18
19pm.request.headers.add({
20 key: "x-api-signature",
21 value: signature
22});
23