daily pastebin goal
75%
SHARE
TWEET

JWTHelper

a guest May 16th, 2018 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     using System;
  2.     using System.Text;
  3.     using Newtonsoft.Json.Linq;
  4.  
  5. public static class JWTHelper
  6. {
  7.     public static string DecodePayload(string jwt)
  8.     {
  9.         string[] tab = jwt.Split('.');
  10.         string payload = tab[1];
  11.         if (payload.Length % 4 > 0)
  12.             payload = payload.PadRight(payload.Length + 4 - payload.Length % 4, '=');
  13.         byte[] data = Convert.FromBase64String(payload);
  14.         string decodedString = Encoding.UTF8.GetString(data);
  15.         JObject json = JObject.Parse(decodedString);
  16.         return (string)json["accountId"];
  17.     }
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top