Generate message signature sha256 postman (base64 is notdefined)

I’m testing an api that i have to send in body those data:
timeStamp (current iso time as a string),
messageSignature: apikey+studentId+timeStamp encrypted using sha256,
i wrote a script to generate message signature,

Details (like screenshots):
in body i wrote:
“messageSignature”: {{$messageSignature}}

Pre-request Script:
var dateIso = new Date().toISOString();
pm.globals.set(“isoDateTostring”, dateIso);
console.log(‘timestamp var is:’, pm.globals.get(“isoDateTostring”));

let msg = “apiKeyvalue” + “studentId” + pm.globals.get(“isoDateTostring”);+ JSON.stringify(msg)

const hmac = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, “secretKey”);
const messageSignature = hmac.finalize().toString();

when i send the request i get base64 is notdefined.


i’ve found the solution in this link i share it with you:errore with messageSignature sha256 in postman (base64 is notdefined.) - Stack Overflow