You are reading a single comment by @MaBe and its replies. Click here to read the full conversation.
  • Found this link and started with this:

    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;
    
    

    Any hints howto?

About

Avatar for MaBe @MaBe started