1 Console.Write("Please enter password: ");
2 while (true)
3 {
4 ConsoleKeyInfo cki = Console.ReadKey(true);
5 if (cki.Key == ConsoleKey.Enter) break;
6 // Append password characters into the SecureString
7 stringBuilder.Append(cki.KeyChar);
8 Console.Write("*");
9 }
10