public static string GenerateTokenString(Jwt jwt, string key)
 {
     return(string.Format(tokenTemplate,
                          Cryptographer.Base64Encode(JsonConvert.SerializeObject(jwt.Header)),
                          Cryptographer.Base64Encode(JsonConvert.SerializeObject(jwt.Payload)),
                          GenerateSignature(jwt, key)));
 }
        private static string GenerateSignature(Jwt jwt, string key)
        {
            string signature = Cryptographer.HMAC_SHA256Encode(string.Format(signatureTemplate,
                                                                             Cryptographer.Base64Encode(JsonConvert.SerializeObject(jwt.Header)),
                                                                             Cryptographer.Base64Encode(JsonConvert.SerializeObject(jwt.Payload))), key);

            jwt.Signature = signature;
            return(signature);
        }