예제 #1
0
        public static String Encode <T>(T payload, Byte[] btKey, JwsHashAlgorithms algorithm) where T : class
        {
            Header header = new Header(algorithm, "JWT");

            Byte[] btHeader  = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(header, Formatting.None));
            Byte[] btPayload = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(payload, Formatting.None));

            String strToSign = Base64Url.Encode(btHeader) + "." + Base64Url.Encode(btPayload);

            Byte[] btToSign    = Encoding.UTF8.GetBytes(strToSign);
            Byte[] btSignATure = dicHashAlgorithms[algorithm](btKey, btToSign);

            return(strToSign + "." + Base64Url.Encode(btSignATure));
        }
예제 #2
0
 public static String Encode <T>(T payload, String strKey, JwsHashAlgorithms algorithm) where T : class
 {
     return(Encode(payload, Encoding.UTF8.GetBytes(strKey), algorithm));
 }
예제 #3
0
 public Header(JwsHashAlgorithms alg, String typ)
 {
     this.alg = alg.ToString(); this.typ = typ;
 }