Password Masking | Sololearn: Learn to code for FREE!

+6

Password Masking

How do you mask a password in an IDE?...a code example will be appreciated...

6/21/2019 11:49:53 AM

ᎯᏰᏰᎯ__ᏥᎿᏩ➰

6 Answers

New Answer

+11

final String password, message = "Enter password"; if( System.console() == null ) { // inside IDE like Eclipse or NetBeans final JPasswordField pf = new JPasswordField(); password = JOptionPane.showConfirmDialog( null, pf, message, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE ) == JOptionPane.OK_OPTION ? new String( pf.getPassword() ) : ""; } else password = new String( System.console().readPassword( "%s> ", message ) );

+11

+5

in case your are ever interested in android development its: given "password" is an EditText variable --> password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);

+4

thank you dear,can you help me with the solution for the one without GUI...

+2

In an IDE? Not sure u can mask it.. Maybe on runtime, user might not see it that's when it can get mask but in an IDE? I doubt..

+1

Mind To Machine 💻🕆 you code Android apps?