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(); }
|
||||
|
|
|
|||
|
|
@ -656,7 +656,7 @@ namespace MinecraftClient
|
|||
var PublicServerkey = Crypto.GenerateRSAPublicKey(Serverkey_RAW);
|
||||
var SecretKey = Crypto.GenerateAESPrivateKey();
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
Console.WriteLine("Handshake sussessful. (Server ID: " + serverID + ')');
|
||||
Console.WriteLine("Handshake successful. (Server ID: " + serverID + ')');
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
return StartEncryption(username, sessionID, token, serverID, PublicServerkey, SecretKey);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,13 +157,12 @@ namespace MinecraftClient
|
|||
if (Settings.Password == "")
|
||||
{
|
||||
Console.Write(ConsoleIO.basicIO ? "Please type the password for " + Settings.Login + ".\n" : "Password : ");
|
||||
Settings.Password = Console.ReadLine();
|
||||
|
||||
Settings.Password = ConsoleIO.basicIO ? Console.ReadLine() : ConsoleIO.ReadPassword();
|
||||
if (Settings.Password == "") { Settings.Password = "-"; }
|
||||
if (!ConsoleIO.basicIO)
|
||||
{
|
||||
//Hide the password
|
||||
Console.CursorTop--;
|
||||
Console.Write("Password : <******>");
|
||||
//Hide password length
|
||||
Console.CursorTop--; Console.Write("Password : <******>");
|
||||
for (int i = 19; i < Console.BufferWidth; i++) { Console.Write(' '); }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue