Exemplo n.º 1
0
        private static string ForgeCookie(string login, byte[] key)
        {
            Span <char> cookie = stackalloc char[100];

            TokenCrypt.Encrypt(key, Encoding.UTF8.GetBytes(login), ref cookie);
            return(cookie.ToString());
        }
Exemplo n.º 2
0
 static bool CheckKey(byte[] plain, byte[] cipher, Span <byte> buffer, byte[] key)
 {
     try
     {
         TokenCrypt.Decrypt(key, cipher, ref buffer);
         return(plain.AsSpan().SequenceEqual(buffer));
     }
     catch
     {
         return(false);
     }
 }