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); } }
public static string ObjectToToken(TokenObject tokenObject, string encryptKey, string encryptIv) { var token = JsonConvert.SerializeObject(tokenObject); return(StringProtector.Protect(token, encryptKey, encryptIv)); }