//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package OpenAny.util;
import java.util.Random;
public final class RandomCode {
private static final char[] numSequence = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
private static final char[] codeSequence = new char[]{'1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
public RandomCode() {
}
public static String getNum(int pDigit) {
Random random = new Random();
StringBuilder randomCode = new StringBuilder();
for(int i = 0; i < pDigit; ++i) {
randomCode.append(String.valueOf(numSequence[random.nextInt(numSequence.length)]));
}
return randomCode.toString();
}
public static String getCode(int pDigit) {
Random random = new Random();
StringBuilder randomCode = new StringBuilder();
for(int i = 0; i < pDigit; ++i) {
randomCode.append(String.valueOf(codeSequence[random.nextInt(codeSequence.length)]));
}
return randomCode.toString();
}
public static String getCode(char[] pCharArray, int pDigit) {
Random random = new Random();
StringBuilder randomCode = new StringBuilder();
for(int i = 0; i < pDigit; ++i) {
randomCode.append(String.valueOf(pCharArray[random.nextInt(pCharArray.length)]));
}
return randomCode.toString();
}
public static String getCode(String pString, int pDigit) {
return getCode(pString.toCharArray(), pDigit);
}
}
生成随机位数的数字或字符代码
最新推荐文章于 2023-06-02 20:28:18 发布