Esempio n. 1
0
        public static string Encode <T>(T data, int time = 10)
        {
            JWTData <T> payload = new JWTData <T> {
                data = data, exp = Authentication.GetNow.AddMinutes(time).ToBinary()
            };

            return(Securities.JWTEncode(payload));
        }
Esempio n. 2
0
        public static T Decode <T>(string token)
        {
            JWTData <T> payload = Securities.JWTDecode <JWTData <T> >(token);

            if (payload != null)
            {
                if (new DateTime(payload.exp) >= Authentication.GetNow)
                {
                    return(payload.data);
                }
            }
            return(default(T));
        }