I am facing an issue while trying to create a token in IONIC using the CryptoJS library. The signature generated by the method is different from what I expect. The expected signature is lLJuDJVb4DThZq/yP4fgYOk/14d3piOvlSuWEI/E7po= but the method provides me with 94b26e0c955be034e166aff23f87e060e93fd78777a623af952b96108fc4ee9a instead. I have thoroughly reviewed the documentation, but it seems like I am overlooking something crucial. Below is the code snippet:
GenerarToken(data)
{
let datos:string = btoa(JSON.stringify(data));
let encabezado:string = btoa(JSON.stringify({
"typ": "JWT",
"alg": "HS256"
}));
let unido:string = encabezado + "." + datos;
var llave = CryptoJS.HmacSHA256(unido, key).toString();
let token = unido + '.' + llave;
return token;
}
The issue arises when creating the signature, as the header and payload seem to be correct.