Not too active here. Little thing I made in a few minutes to generate peudo-random passwords. Enjoy.
NOTE: The way to use this should be obvious, but if it's not, the proper usage is 'java PasswordGenerator [length (The length your password should be)] [number (the number of passwords to generate)]'
Code:
import java.util.*;
import java.security.*;
class PasswordGenerator {
public static String alph = "abcdefghijklmnopqrstuvwxyz";
public static void main(String[] args) {
if(args.length == 2) {
int length = 0;
int times = 0;
try {
length = Integer.parseInt(args[0]);
times = Integer.parseInt(args[1]);
} catch (RuntimeException e) {
System.out.println("Invalid args! Type 'java PasswordGenerator --help' for help");
}
for(int i1=0; i1<times; i1++) {
SecureRandom random = new SecureRandom();
StringBuilder builder = new StringBuilder();
for(int i2=0; i2<length; i2++) {
int rand = random.nextInt(2);
switch(rand) {
case 0:
builder.append((random.nextInt(10)));
break;
case 1:
builder.append(((random.nextInt(2) == 0) ? (Character.toString(alph.charAt(random.nextInt(24)))).toUpperCase().toCharArray()[0] : (Character.toString(alph.charAt(random.nextInt(24)))).toLowerCase().toCharArray()[0]));
break;
}
}
System.out.println("Password" + '[' + i1 + ']' + ": " + builder.toString());
}
} else if((args.length == 1) && args[0].equals("--help")) {
System.out.println("Usage: java PasswordGenerator [length] [number]" + '\n' +
" (Integer) length: The length each password should be" + '\n' +
" (Integer) number: The number of passwords to generate"
);
} else {
System.out.println("Invalid args! Type 'java PasswordGenerator --help' for help");
}
}
}












