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) {
Random random = new Random();
return Math.abs(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);
}
}
复杂密码生成器
最新推荐文章于 2023-12-19 10:50:28 发布