Guest User

Mikail - Password

a guest
Nov 12th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. public static string Returnpassword()
  2. {
  3.     Console.WriteLine("Provide a valid machine or domain account. [domain\\user]");
  4.     Console.WriteLine("   Enter username:");
  5.     string username = Console.ReadLine();
  6.     Console.WriteLine("   Enter password:");
  7.     string password = "";
  8.     ConsoleKeyInfo info = Console.ReadKey(true);
  9.     while (info.Key != ConsoleKey.Enter)
  10.     {
  11.         if (info.Key != ConsoleKey.Backspace)
  12.         {
  13.             password += info.KeyChar;
  14.             info = Console.ReadKey(true);
  15.         }
  16.         else if (info.Key == ConsoleKey.Backspace)
  17.         {
  18.             if (!string.IsNullOrEmpty(password))
  19.             {
  20.                 password = password.Substring
  21.                 (0, password.Length - 1);
  22.             }
  23.             info = Console.ReadKey(true);
  24.        }
  25.     }
  26.     for (int i = 0; i < password.Length; i++)
  27.     Console.Write("*");
  28. return password;
  29.     }
Add Comment
Please, Sign In to add comment