Codelog

foreach(Snippet aSnippet in CodeLog){ aSnippet.GetSolution(); }

Archive for the ‘password masking’ tag

Password Masking in CLI using Java

with one comment

Java CLI password masking was appended to Java 6. Wonder why it took them so long to add it. It comes with the Console Class. This class has several features for the ones developing CLI programs. I always hated the method to mask the letters with another thread.

Here is a sample,

import java.io.Console;

class pass {

public static void main (String[] args) {

    char passwd[];
    Console cons = System.console();
    passwd = cons.readPassword(" Enter Your Password : ");
    System.out.println("The Password is : " +passwd);
}
}

Here is the Documentation Link http://java.sun.com/javase/6/docs/api/java/io/Console.html.

In my next post I’ll describe a simple Encryption and Decryption of this password.

Written by danish

August 26th, 2008 at 4:17 pm

Posted in Java

Tagged with , ,