package cn.wisenergy.common.utils;

import java.util.Random;

/**
 * 生成充值卡子卡秘钥工具类
 * @author 86187
 */
public class SecretkeyUtil {

    //字符串长度
    static final int LENGTH= 16;

    //开头数字最小长度
    static final int MIN_LENGTH_OF_NUMBER= 4;

    //字母拼接最大位置
    static final int MAX_LENGTH_OF_STRING=11;
    public static String getSecretkey(){
        char[] chars={'a','b','c','d','e','f','g','h','l','j','k','i','m','n','o','p','q','r','s','t','y','u','w','x','v','z'};
        StringBuilder stringBuilder=new StringBuilder(16);
        Random random = new Random();
        int i1 =random.nextInt(4)+MIN_LENGTH_OF_NUMBER;
        for (int i = 0; i <i1; i++) {
            stringBuilder.append(random.nextInt(9));
        }
        while (i1<MAX_LENGTH_OF_STRING) {
            int i2 =random.nextInt(25);
            if (i2 < 26) {
                stringBuilder.append(chars[i2]);
                i1++;
            }

        }
        for (int i = MAX_LENGTH_OF_STRING; i <LENGTH ; i++) {
            stringBuilder.append(random.nextInt(9));
        }

        return stringBuilder.toString();
    }
}
