I'm pretty new to Java & just made a login, but I want to hide the password with stars. But if I use this snippet it will use the stars. How can I 'encode' it after replacing?
EDIT: The input is from a GuiTextBox, its a method of GuiScreen of Minecraft.
String input = passwd.getText();
char ca = new char[input.length()];
String output = new String(ca);
You are trying to recreate something already existing.
Java provide the JPasswordField that will do exactly what you want directly.
This is used easily like a
JTextField but hidding the password on keystroke. And you have this solution to get the value (can't remember if getText() return the value too)
char input = passwordField.getPassword();
See this guide for more information
Since this is not a Swing component and I don't know it, I will give you an ugly solution ;)
You need to keep the
input variable in memory. So instead of declaring
input in the methods where you replace the value, declare it outside the methods (to be an instance variable)