Random Key Generator Sample For JAVA
Code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package RandomKeys;
import java.util.Random;
/**
*
* @Author https://kat.cr/user/DickCheny/
*/
public class SteamKey {
private static final String uCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
private static Random r = new Random();
private static String pass = "";
private static String pass1 = "";
private static String pass2 = "";
private static String pass3 = "";
public static void main (String[] args) {
System.out.println ("Generating pass...");
while (pass.length () != 5){
int rPick = r.nextInt(5);
if (rPick == 0){
int spot = r.nextInt (36);
pass += uCase.charAt(spot);
}
while (pass1.length () != 5){
int rPick1 = r.nextInt(5);
if (rPick1 == 0){
int spot = r.nextInt (36);
pass1 += uCase.charAt(spot);
}
while (pass2.length () != 5){
int rPick2 = r.nextInt(5);
if (rPick2 == 0){
int spot = r.nextInt (36);
pass2 += uCase.charAt(spot);
}
while (pass3.length () != 5){
int rPick3 = r.nextInt(5);
if (rPick3 == 0){
int spot = r.nextInt (36);
pass3 += uCase.charAt(spot);
}
}
}
}
}
System.out.println ("Generated Pass: " + pass + "-" + pass1 + "-" + pass2 + "-" + pass3);
}
}
Note: You need JRE and JDK to run it in CMD. If not use Netbeans/DrJava/Eclipse/etc. (Copy paste and run it)