复杂密码生成器

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
import java.util.*;

public class Main {
private static final String []range = new String[5];
private static int[] sum = new int[10];
private static void init() {
range[0] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
range[1] = "abcdefghijklmnopqrstuvwxyz";
range[2] = "0123456789";
range[3] = "~!@#$%^&*()_+/-=[]{};:'<>?.";
}

private static int nextInt(int len) {
return Math.abs(new Random().nextInt(len));
}

private static char getChar(int op) {
return range[op].charAt(nextInt(range[op].length()));
}
private static char getRand() {
int op = nextInt(4);
return getChar(op);
}

public static void main(String[] args) {
init();
StringBuffer s = new StringBuffer();
Arrays.fill(sum, 0);
for (int i = 0; i < 16; i++) {
s.append(getRand());
}
for (int i = 0; i < 4; i++) {
if (sum[i] == 0) {
s.append(getChar(i));
}
}
System.out.println(s);
}
}


复杂密码生成器
http://example.com/2022/05/01/复杂密码生成器/
Author
John Doe
Posted on
May 1, 2022
Licensed under