I have the following js code:
function getSlideAnswer(responseId, fpToken, coordinateX, traceData) {
coordinateX = Math.floor(coordinateX);
var encryptData = {
"track": traceData,
"x": coordinateX + "",
"p": "0,0",
"finger": fpToken
};
var t = CryptoJS.enc.Utf8.parse(responseId.substr(0, 16));
return CryptoJS.AES.encrypt(JSON.stringify(encryptData), t, {
iv: t,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
}).ciphertext.toString().toUpperCase();
}
However, I receive the following error:
execjs._exceptions.ProgramError: TypeError: 'JSON' is undefined
How to solve the error?
You can replace strigify by string concatenation in JS or Python.
Not sure about parameter types, but an example in JS: