import java.util.Random;
public class PasswordGeneration2 {
static String passwordGenerator2() {
int length = 15;
String password = "";
String numbers = "1234567890";
String speacialCharacters = "!@#$%";
// String speacialCharacters = "";
String upperCaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
String lowerCaseLetters = "abcdefghijklmnopqrstuvwxyz";
String passowrConcat = upperCaseLetters + lowerCaseLetters + speacialCharacters + numbers;
Random random = new Random();
for (int i = 0; i < length; i++) {
int index = random.nextInt(passowrConcat.length());
password += passowrConcat.charAt(index);
}
return password;
}
public static void main(String[] args) {
String retValue = passwordGenerator2();
}
}
No comments:
Post a Comment