Masking a password with the Console class

20/12/2011 10:21

import java.io.Console;

public class Main {

  public static void main(String[] args) {
    Console console = System.console();

    char passwordArray[] = console.readPassword("Enter your secret password: ");
    console.printf("Password entered was: %s%n"new String(passwordArray));
  }
}

Back

Search site

Copyright © 2012 Dadaso Zanzane. All rights reserved.