1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
import java.io.Console;
public class ConsoleInput {
public static void main(String[] args) {
Console console = System.console();
String titleUser = "Please enter value";
String label = "[Encrypted value]:";
String titlePWD = "password:";
String description = "Please enter a Digit:: 0: Start encrypt words 1: Exit";
String flag ="0";
if(console!=null){
while("0".equals(flag.trim())) {
String srcWord = console.readLine("[%s]:", titleUser);
console.printf("%s", label + srcWord);
console.flush();
System.out.println();
System.out.println(description);
flag =console.readLine();
System.out.println();
char[] password = console.readPassword("[%s]", titlePWD);
String strPassword = String.valueOf(password);
java.util.Arrays.fill(password, '*');
console.printf("%s", titlePWD + String.valueOf(password));
console.flush();
System.out.println();
}
}
}
}
|