Exemplo n.º 1
0
        public static string DeTokenize(string token, int maxDays = 14)
        {
            var decoded = Base64StringDecode(token).Split('|');

            long ticks;

            if (!long.TryParse(decoded[0], out ticks))
            {
                return(null);
            }

            if (Math.Abs((DateTime.UtcNow - new DateTime(ticks)).TotalDays) > maxDays)
            {
                throw new TokenExpiredException();
            }

            return(Aes256Encryption.DecryptString(decoded[1], CreateKey(decoded[0])));
        }
Exemplo n.º 2
0
        public static string Tokenize(string args)
        {
            var ticks = DateTime.UtcNow.Ticks.ToString();

            return(Base64StringEncode(ticks + "|" + Aes256Encryption.Encrypt(args, CreateKey(ticks))));
        }
Exemplo n.º 3
0
        private static byte[] CreateKey(string t)
        {
            var seed = int.Parse(MaxLength(t, 9));

            return(Aes256Encryption.CreateKey(seed));
        }