Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string Returnpassword()
- {
- Console.WriteLine("Provide a valid machine or domain account. [domain\\user]");
- Console.WriteLine(" Enter username:");
- string username = Console.ReadLine();
- Console.WriteLine(" Enter password:");
- string password = "";
- ConsoleKeyInfo info = Console.ReadKey(true);
- while (info.Key != ConsoleKey.Enter)
- {
- if (info.Key != ConsoleKey.Backspace)
- {
- password += info.KeyChar;
- info = Console.ReadKey(true);
- }
- else if (info.Key == ConsoleKey.Backspace)
- {
- if (!string.IsNullOrEmpty(password))
- {
- password = password.Substring
- (0, password.Length - 1);
- }
- info = Console.ReadKey(true);
- }
- }
- for (int i = 0; i < password.Length; i++)
- Console.Write("*");
- return password;
- }
Add Comment
Please, Sign In to add comment