public static void main(String[] args) {String val =genSixToSixteenPsw();System.out.println("企业中征码为:" + val);}public static String genSixToSixteenPsw() {String val = "";Random random = new Random();int numbers = 14;for (int i = 0; i < numbers; i++) {String charOrNum = random.nextInt(2) % 2 == 0 ? "char" : "num";if ("char".equalsIgnoreCase(charOrNum)) {int choice = random.nextInt(2) % 2 == 0 ? 65 : 97;val += (char) (choice + random.nextInt(26));} else if ("num".equalsIgnoreCase(charOrNum)) {val += String.valueOf(random.nextInt(10));}}return checkZZM(val.toUpperCase());}public static String checkZZM(String value) {if (value.length()!=14) {return "";}char[] idCode = value.substring(0, 14).toCharArray();int[] weight_factor = new int[]{1, 3, 5, 7, 11, 2, 13, 1, 1, 17, 19, 97, 23, 29};int len = idCode.length;int num = 0;int temp = 0;for (int i = 0; i < len; i++) {if (idCode[i] >= 'A' && idCode[i] <= 'Z') {temp = (int) idCode[i] - 55;} else {temp = (int) idCode[i] - 48;}num = num + temp * weight_factor[i];}int resisue = num % 97 + 1;System.out.println("生成2位验证码为:"+resisue);value = value + resisue;if (value.length()!=16) {return "";}return value;}