Ejemplo n.º 1
0
 public static bool TokenToObject(string token, string encryptKey, string encryptIv, out TokenObject tokenObject)
 {
     tokenObject = new TokenObject();
     try
     {
         if (string.IsNullOrEmpty(token))
         {
             return(false);
         }
         token       = StringProtector.Unprotect(token, encryptKey, encryptIv);
         tokenObject = JsonConvert.DeserializeObject <TokenObject>(token);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Ejemplo n.º 2
0
        public static string ObjectToToken(TokenObject tokenObject, string encryptKey, string encryptIv)
        {
            var token = JsonConvert.SerializeObject(tokenObject);

            return(StringProtector.Protect(token, encryptKey, encryptIv));
        }