Skip to content

Instantly share code, notes, and snippets.

@hhhaiai
Created July 30, 2020 07:55
Show Gist options
  • Save hhhaiai/e99cb0a2df398b226c4b199dc5008480 to your computer and use it in GitHub Desktop.
Save hhhaiai/e99cb0a2df398b226c4b199dc5008480 to your computer and use it in GitHub Desktop.
public static String randomSerialNumber() {
String str[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I",
"J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
StringBuilder sb = new StringBuilder();
Random random = new Random(System.nanoTime());
for (int i = 0; i < 16; i++) {
int iRand = random.nextInt(str.length);
String charmac = str[iRand];
sb.append(charmac);
}
return sb.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment