public static APIToken Create(long keyId) { var returnToken = new APIToken(); returnToken._keyId = keyId; return(returnToken); }
public static APIToken ParseToken(string cipher) { APIToken returnToken = null; if (!string.IsNullOrEmpty(cipher)) { var data = Crypto.Crypto.Decrypt(cipher, CryptoPassword, CryptoSalt); MemoryStream s = new MemoryStream(); s.Write(data, 0, data.Length); s.Position = 0; BinaryFormatter bf = new BinaryFormatter(); string[] outData = (bf.Deserialize(s) as string).Split("|".ToCharArray()); long apiKey = long.Parse(outData[0]); returnToken = new APIToken(); returnToken._keyId = apiKey; returnToken._timestamp = long.Parse(outData[1]); } return(returnToken); }