mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Added password obfuscation while typing
Each character of the password is replaced by a star while typing + Fixed an old typo for "Handshake successfull" (ss -> cc).
This commit is contained in:
parent
f26ff323fd
commit
f7835e7f60
3 changed files with 47 additions and 6 deletions
|
|
@ -24,6 +24,48 @@ namespace MinecraftClient
|
|||
private static bool writing_lock = false;
|
||||
|
||||
#region Read User Input
|
||||
public static string ReadPassword()
|
||||
{
|
||||
string password = "";
|
||||
ConsoleKeyInfo k = new ConsoleKeyInfo();
|
||||
while (k.Key != ConsoleKey.Enter)
|
||||
{
|
||||
k = Console.ReadKey(true);
|
||||
switch (k.Key)
|
||||
{
|
||||
case ConsoleKey.Enter:
|
||||
Console.Write('\n');
|
||||
return password;
|
||||
|
||||
case ConsoleKey.Backspace:
|
||||
if (password.Length > 0)
|
||||
{
|
||||
Console.Write("\b \b");
|
||||
password = password.Substring(0, password.Length - 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case ConsoleKey.Escape:
|
||||
case ConsoleKey.LeftArrow:
|
||||
case ConsoleKey.RightArrow:
|
||||
case ConsoleKey.Home:
|
||||
case ConsoleKey.End:
|
||||
case ConsoleKey.Delete:
|
||||
case ConsoleKey.Oem6:
|
||||
case ConsoleKey.DownArrow:
|
||||
case ConsoleKey.UpArrow:
|
||||
case ConsoleKey.Tab:
|
||||
break;
|
||||
|
||||
default:
|
||||
Console.Write('*');
|
||||
password += k.KeyChar;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return password;
|
||||
}
|
||||
|
||||
public static string ReadLine()
|
||||
{
|
||||
if (basicIO) { return Console.ReadLine(); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue