+ 2

How do I hide/encode an user input in a console application? (C#)

7th Sep 2017, 8:32 PM
Gonzalo Zuñiga
Gonzalo Zuñiga - avatar
2 Respostas
+ 4
I've been working on a login process for my Entity project. You can use this if it's any help? Note: Will only work in Visual Studio, not code playground. If not let me know what you need. using System.Security; static void Main(string[] args) { Console.Write("--|> PASSWORD: "); SecureString pass = new SecureString(); ConsoleKeyInfo key; do { key = Console.ReadKey(true); if (key.Key != ConsoleKey.Backspace) { pass.AppendChar(key.KeyChar); Console.Write("*"); } else { pass.RemoveAt(pass.Length - 1); Console.Write("\b \b"); } } while (key.Key != ConsoleKey.Enter); } It basically swaps user input for *.
7th Sep 2017, 8:53 PM
Bagshot
Bagshot - avatar
+ 1
Omg that's perfect and it works so well, Thank you so much Indeed I was looking for a code that worked on VS :D PD: sorry my english and again, thank you
8th Sep 2017, 8:09 PM
Gonzalo Zuñiga
Gonzalo Zuñiga - avatar