public String randomCodeL(){
String code = "";
// 26个字母
int size = 26;
// 验证码位数
int imgNum = 6;
Random r = new Random();
int count = 0;
while(count < imgNum){
int nextInt = r.nextInt(size * 2);
int num = (int)a;
if(nextInt >= size){
num = (int)A;
nextInt -= 26;
}
int c = num + nextInt;
char cc = (char)c;
if(code.indexOf(cc) == -1){
code += cc;
count++;
}
}
return code;
}
Java_6位随机字母验证码,大小写
最新推荐文章于 2023-04-18 18:34:26 发布