package net.acomputerdog.core.gen;

import java.util.Random;

public class StringGen {
    private static final Random random = new Random("StringGen".hashCode() + System.currentTimeMillis());
    private static final char[] alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZ".toCharArray();

    public static int nextInt() {
        return random.nextInt();
    }

    public static String nextString(int length) {
        byte[] bytes = new byte[length];
        random.nextBytes(bytes);
        limBytes(bytes, (byte) alphabet.length);
        return createString(bytes);
    }

    public static String nextString() {
        return nextString(8);
    }

    private static String createString(byte[] bytes) {
        char[] chars = new char[bytes.length];
        for (int index = 0; index < bytes.length; index++) {
            bytes[index] = (byte) (bytes[index] % chars.length);
        }
        return new String(chars);
    }

    private static byte[] limBytes(byte[] bytes, byte max) {
        for (int index = 0; index < bytes.length; index++) {
            bytes[index] %= max;
        }
        return bytes;
    }
}

@@ -59,32 +59,163 @@
 m;%0A%0A
-public class StringGen %7B
+/**%0A * Utility class for generating (insecure) random strings%0A */%0Apublic class StringGen %7B%0A    /**%0A     * Instance of Random for generating strings%0A     */
 %0A   
@@ -316,16 +316,96 @@
 llis());
+%0A%0A    /**%0A     * %22Alphabet%22 of characters to use when generating Strings%0A     */
 %0A    pri
@@ -492,16 +492,27 @@
 RSTUVXYZ
+01234567890
 %22.toChar
@@ -529,77 +529,163 @@
     
-public static int nextInt() %7B%0A  
+/**%0A     * Creates a string of the specified length%0A     *%0A     * @param length The length of the string%0A
      
- 
+* @
 return 
-random.nextInt();
+Return the generated string
 %0A    
-%7D%0A
+ */
 %0A   
@@ -866,131 +866,327 @@
     
-return createString(bytes);
+char%5B%5D chars = new char%5Bbytes.length%5D;%0A        for (int index = 0; index %3C bytes.length; index++) %7B
 %0A    
-%7D%0A%0A
     
-public static String next
+    bytes%5Bindex%5D = (byte) (bytes%5Bindex%5D %25 chars.length);%0A        %7D%0A        return new 
 String(
-) %7B%0A        return next
+chars);%0A    %7D%0A%0A    /**%0A     * Gets a random 8-character String%0A     * @return The generated 
 String
-(8);
+.
 %0A    
-%7D%0A
+ */
 %0A    p
-rivate
+ublic
  sta
@@ -1200,260 +1200,284 @@
 ing 
-create
+next
 String(
-byte%5B%5D bytes) %7B%0A        char%5B%5D chars = new char%5Bbytes.length%5D
+) %7B%0A        return nextString(8)
 ;%0A    
+%7D%0A%0A
     
-for (int index = 0; index %3C bytes.length; index++) %7B%0A            bytes%5Bindex%5D = (byte) (bytes%5Bindex%5D %25 chars.length);%0A        %7D%0A        return new String(chars);
+/**%0A     * Limits an array of bytes to a certain max value using modulus%0A     * @param bytes The bytes to limit%0A     * @param max The value to limit to%0A     * @return Return the array of bytes with limited values
 %0A    
-%7D%0A
+ */
 %0A   

Comment StringGen