So sorry if this is in the wrong section, I am new to this forums
So guys i just quickly made this, can y'all tell me if its alright, like if it is effiiant, if not can you explain how I can make this really efficient, please note this is not a 'serial' key generator to unlock software or anything
import java.util.Random; /** * This class is used to auto generate random codes * Made this just as an experiment * @author Zack * */ public class RandomCodeGenerator { /** * This is all the Keys that can be made in the code generator */ private static String[] keys = { "1", "2", "3", "4", "5", "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" }; /** * This is the String for the code */ static StringBuilder sb = new StringBuilder(); /** * This variable determains how much codes you generate */ public final static int REPEAT = 10000; /** * This variable counts how much characters will be in the code itself */ public final static int CHARACTERS = 25; /** * This variable places a dash after a certain amount of characrtes, so for instance * if it is set to 5 it will put a dash after every 5 characters */ public final static int DASH = 5; /** * This will generate a randomized code and return the value * @return StringBuilders value, all the Strings that have been appended */ public static String generateCode(){ Random r = new Random(); int counter = 0; int dashCounter = 0; sb.delete(0, CHARACTERS); for(int i = 1; i <= CHARACTERS; i++){ sb.append(keys[r.nextInt(keys.length - 1)]); counter++; if(counter == DASH){ dashCounter++; if(dashCounter == CHARACTERS / DASH){ } else { sb.append("-"); counter = 0; } } } return sb.toString(); } /** * This is the main method that will repeat the code generator * @param args */ public static void main(String[] args) { for(int i = 0; i < REPEAT; i++){ System.out.println(generateCode()); sb.delete(0, CHARACTERS); } } }
here is an example how the codes look
BQ935-14CKK-64Z8N-PLESN-HHBDZ 5H45P-MEC9H-NM2TA-FF22S-XQX6L P7BXD-FUM21-JRY5R-GVNEM-KIU4B W5WTI-AKYEM-NO7EN-UUWG4-5NO7R XUB43-3BZTY-K3FBK-Z9HDS-PHUDF RDTUA-X9USV-CUPWN-8Q92J-IOOVC YJS3E-D5GJS-3COPL-SLU33-TB8SU UGHI1-7KW1O-XPLTN-S4DEF-5USVE TP4GI-C6OE5-CI8CM-4BAC2-M88BU RK7RZ-BGK1V-WZS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