public string Renew(string token) { CryptData crypto = new CryptData(CryptKey); var tokenArray = token.Split(';'); Guid guid = Guid.Parse(crypto.DecryptData(tokenArray[0])); var username = crypto.DecryptData(tokenArray[1]); DateTime lastActivityTime = DateTime.Parse(crypto.DecryptData(tokenArray[2]).Replace(" ?.?", "")); int tokenLifeTime = int.Parse(System.Configuration.ConfigurationManager.AppSettings["TokenLifTime"].ToString()); lastActivityTime = lastActivityTime.AddMinutes(tokenLifeTime); return(crypto.EncryptData(Guid.NewGuid().ToString()) + ";" + crypto.EncryptData(username) + ";" + crypto.EncryptData(lastActivityTime.ToString()) + ";ToKEn"); }
public string Generate(string username) { CryptData crypto = new CryptData(CryptKey); return(crypto.EncryptData(Guid.NewGuid().ToString()) + ";" + crypto.EncryptData(username) + ";" + crypto.EncryptData(DateTime.Now.ToString()) + ";ToKEn"); }