var header = {
"alg": "HS256",
"typ": "JWT"
};
var data = {
"id": 1337,
"username": "john.doe"
};
var encodedHeader = btoa(JSON.stringify(header));
var encodedData = btoa(JSON.stringify(data));
var token = encodedHeader + "." + encodedData;
var secret = "My very confidential secret!";
print(token);
/* struggled at this point, no clue if there i an existing solution for this
var signature = CryptoJS.HmacSHA256(token, secret);
*/
signature = btoa(signature);
var signedToken = token + "." + signature;
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Found this link and started with this:
Any hints howto?