UPD: Adding camelcase support and shorten password length
This commit is contained in:
parent
822b346df0
commit
9dd4bc0b4e
BIN
java/RandomPassword/PasswordGenerator.class
Normal file
BIN
java/RandomPassword/PasswordGenerator.class
Normal file
Binary file not shown.
@ -7,7 +7,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class PasswordGenerator {
|
||||
private static final int DEFAULT_PASSWORD_LENGTH = 4;
|
||||
private static final int DEFAULT_PASSWORD_LENGTH = 3;
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
@ -41,11 +41,15 @@ class PasswordGenerator {
|
||||
for (int i = 0; i < length; i++) {
|
||||
int randomIndex = random.nextInt(dictionary.size());
|
||||
String word = dictionary.get(randomIndex);
|
||||
passwordBuilder.append(word);
|
||||
passwordBuilder.append(toCamelCase(word));
|
||||
if ( i < length-1) {
|
||||
passwordBuilder.append("/");
|
||||
}
|
||||
}
|
||||
return passwordBuilder.toString();
|
||||
}
|
||||
|
||||
private static String toCamelCase(String inputString) {
|
||||
return inputString.substring(0,1).toUpperCase() + inputString.substring(1).toLowerCase();
|
||||
}
|
||||
}
|
||||
|
BIN
java/RandomPassword/passwordgenerator
Executable file
BIN
java/RandomPassword/passwordgenerator
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user