public class Main {public static void main(String[] args) {//企业中征码为 16位 后2位位验证码String checkZZM = checkZZM( String.valueOf((int)(Math.random()*10+1)) + String.valueOf(System.currentTimeMillis()) );System.out.println("企业中征码为:" + checkZZM);}//校验中征码public static String checkZZM(String value) {//判断中征码前14位if (value.length()!=14) {return "";}//前14位转化为char数组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];}//取余+1int resisue = num % 97 + 1;System.out.println("生成2位验证码为:"+resisue);//拼接验证码value = value + resisue;//判断中征码是否为16位if (value.length()!=16) {return "";}return value;} }