| Author |
random password generation
|
Amit Babu
Greenhorn
Joined: Dec 09, 2005
Posts: 9
|
|
What sort of algorithm can be used for random password generation? I do not want a very complex algorithm. A simple but effective approach would be highly appreciated. [ December 13, 2005: Message edited by: Amit Babu ]
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12928
|
|
Simply create a java.util.Random object and write a loop to have it generate some random numbers (integers), and cast them to characters. For example:
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12269
|
|
Since certain character pairs are hard to distinguish in many fonts, you might consider discarding upper case i and l (I l) upper case o and zero (O 0 ) etc. Those of us with aging vision will thank you. Bill
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
I select random characters from an array: characters = "bcdfghjklmnpqrstvwxz23456789" ... get Byte Array ... I leave out I O and 1 0 to avoid confusion as suggested above, and all vowels to avoid offensive words in any language except Qwlghm. Any time this random password question comes up, I drag up CompuServe, the great online giant of the 80s and 2400 baud modems. Their passwords were two randomly chosen dictionary words. Mine was "water boldly". It's certainly easier to remember (for the last 25 years) than a random string of letters and digits.
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
Amit Babu
Greenhorn
Joined: Dec 09, 2005
Posts: 9
|
|
Originally posted by Jesper de Jong: Simply create a java.util.Random object and write a loop to have it generate some random numbers (integers), and cast them to characters. For example:
This is eaxctly what I had in mind. Glad to know that this could be a good algorithm.
|
 |
 |
|
|
subject: random password generation
|
|
|