Generate message signature sha256 postman (base64 is notdefined)

I’m testing an api that i have to send in body those data:
studentId,
apiKey,
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:
{
“studentId”:“",
“apiKey”:"
****”,
“timeStamp”:{{$isoDateTostring}},
“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”);
hmac.update(msg);
const messageSignature = hmac.finalize().toString();

when i send the request i get base64 is notdefined.

image

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