java-faker
java-faker copied to clipboard
Add ability to init special characters
Problem: Currently, special characters are hardcoded.
Solution: It would be great if it would be possible to init / set / reload special characters.
Code, where special characters are used:
public String password(int minimumLength, int maximumLength, boolean includeUppercase, boolean includeSpecial, boolean includeDigit) {
if (includeSpecial) {
char[] password = faker.lorem().characters(minimumLength, maximumLength, includeUppercase, includeDigit).toCharArray();
char[] special = new char[]{'!', '@', '#', '$', '%', '^', '&', '*'};
for (int i = 0; i < faker.random().nextInt(minimumLength); i++) {
password[faker.random().nextInt(password.length)] = special[faker.random().nextInt(special.length)];
}
return new String(password);
} else {
return faker.lorem().characters(minimumLength, maximumLength, includeUppercase, includeDigit);
}
}
Do you mean that it should provide an interface to let user set the desired special letters?
I would be happy to volunteer to work on this feature in Oct/Nov for an academic project.
Pull Request #669 ["Add passwords with user-specified special characters"] has been submitted to add this feature.