자바 12자리 랜덤함수 호출 알고리즘

자바 12자리 랜덤함수 호출 알고리즘


1
2
3
4
5
6
7
8
9
10
11
public static String getRtNum(int length) {
int nSeed = 0;
int nSeedSize = 62; // 숫자 + 영문
String strSrc = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; // 숫자, 영문
String strKey = "";
for(int i=0; i<length; i++){
nSeed = (int)(Math.random() * nSeedSize) + 1;
strKey += String.valueOf(strSrc.charAt(nSeed-1));
}
return strKey;
}
Share