• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

random password generation

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Amit Babu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
What I don't understand is how they changed the earth's orbit to fit the metric calendar. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic