Auto generate password

Hellocan 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
[193 byte] By [azadehhomayouna] at [2007-11-26 18:17:11]
# 1
Build a string array with the alphabet in lowercases, build another string array but with upper cases, build an int array with int from 0 to 9 and then make some random access on them to grab the passwordregards,Manuel Leiria
manuel.leiriaa at 2007-7-9 5:50:45 > top of Java-index,Java Essentials,Java Programming...
# 2

> 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

Sq2000a at 2007-7-9 5:50:45 > top of Java-index,Java Essentials,Java Programming...
# 3

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>

AbiSSa at 2007-7-9 5:50:45 > top of Java-index,Java Essentials,Java Programming...
# 4
thank you so muchyou really helped me a lot
azadehhomayouna at 2007-7-9 5:50:45 > top of Java-index,Java Essentials,Java Programming...
# 5
Pleasure is all mine ;-)I love u Java - My Valentine -TC
AbiSSa at 2007-7-9 5:50:45 > top of Java-index,Java Essentials,Java Programming...