|
-
May 27th, 2007, 07:53 AM
#1
Thread Starter
New Member
Choosing a random vector and choosing a random value
Hi,
I'm working on a program that can generate random passwords. I've got a JComboBox in which the user can choose the PasswordLength. Then, when the user clicks on the Generate-button, a random password is generated.
I've got 3 vectors:
The first vector contains digits from 0 to 9.
The second vector contains the alphabet in lower case.
The third vector contains the alphabet in upper case.
When the user presses the Generate-button, the method GeneratePassword() is invoked. But I don't exactly know how to write that method.
For every place in the password, the program must choose a random vector out of the three vectors mentioned above, to pick a value from.. and then choose a random value. For the next place in the password, this operation must be repeated.
The method GeneratePassword() is empty now:
Code:
public String GeneratePassword() {
for(int i = 0; i < Integer.parseInt((String)cPasswordLength.getSelectedItem()); i++) {
}
}
Using a for-statement, the method should go to the next place in the password to be generated.
So, anyone wants to help?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|