title: How to generate Encrypted JWT token in c#
body: <p>using the below code I could able to generate the encrypted JWT Token. But it is giving 5 parts.  I need only 3 parts. so could any help me in getting the desired code.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>  var jwt = new JwtSecurityToken(
                  issuer: "asds",
                  audience: "sds",
                  claims: cliams,
                  notBefore: DateTime.Now,
                  signingCredentials: signingCredentials,
                  expires: DateTime.Now.AddHours(1)
  
  
  
                  );
  
  
              var ep = new Microsoft.IdentityModel.Tokens.EncryptingCredentials(securityKey1, Microsoft.IdentityModel.Tokens.SecurityAlgorithms.Aes256KW, Microsoft.IdentityModel.Tokens.SecurityAlgorithms.Aes256CbcHmacSha512);
              JwtSecurityTokenHandler tokenHandler = new JwtSecurityTokenHandler();
              var a = tokenHandler.CreateJwtSecurityToken("issuer", "Audience", new ClaimsIdentity(cliams), DateTime.Now, DateTime.Now.AddHours(1), DateTime.Now, signingCredentials, ep);
              string tokenString2 = tokenHandler.WriteToken(a);
  
              Console.WriteLine("Token string: {0}", tokenString);
  
  
              var encodedtext = new JwtSecurityTokenHandler().WriteToken(a);</code></pre>
  </div>
  </div>
  </p>