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()); }
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); } }