> Hello
> can someone tell me how to generate a password
> automatically that have at least one lower case
> letter, one uppercase letter and number and be at
> least 8 letters.
> thanks
You can make arrays of your desired lengths an integer and string arrays, then populate your respective arrays with random strings and numbers. then grab one letter among your strings then convert it to upper case using the respective string method. Grab one number from from the other array (integer array) do this by reading the contents into a vector of objects to manufacture your password. then read your vector and typecast it into a string. be aware of unchecked operations errors.
thanks
Sq2000
public class pwdGen {
public static void main(String[] args) {
Random r = new Random();
for(int i=0;i<127;i++){
ArrayList AL = new ArrayList();
//No of Big letters
int a1 = r.nextInt(6)+1;
//No of small
int a2 = r.nextInt(7-a1)+1;
//no on nos
int a3 = 8-a1-a2;
for(int j=0;j<a1;j++){
char c1= (char) (r.nextInt(26)+65);
AL.add(new Character(c1));
}
for(int j=0;j<a2;j++){
char c1= (char) (r.nextInt(26)+97);
AL.add(new Character(c1));
}
for(int j=0;j<a3;j++){
char c1= (char) (r.nextInt(9)+48);
AL.add(new Character(c1));
}
Collections.shuffle(AL);
System.out.println("pwd = "+AL.toString().replaceAll(",",""));
}
}
}
Yeah I was jobless ;-)
Lots of room for improvement though
Now have sme wrk so couldn fine tune
-TC>