• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Random string generation

 
Anna Hays
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, can Java generate a string of random charactors? I need a password generation. Can someone give me an idea of what's the proper way of doing this please? Thanks.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This might be one way

 
Steve Deadsea
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote libraries for doing this:
http://ostermiller.org/utils/RandPass.html
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Anna Kafei:
Hi, can Java generate a string of random charactors? I need a password generation. Can someone give me an idea of what's the proper way of doing this please? Thanks.


1. Specified your data for random.
2. Specified length for generate password.
3. Create random utilities , you can use Math.random() method or java.util.Random class.
 
Ian Darwin
author
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Everybody has their own idea; here's one I've used on a couple of projects.

But since I never like to ship code without testing it:

Cheers

Ian

[fixed some formatting - Jim]
[ October 13, 2004: Message edited by: Jim Yingst ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a long enough password space another good technique is to take a large dictionary and randomly choose two words. These are much easier to remember than a string of random letters & numbers. I still recall my original CompuServe password from the 80s was "water boldly".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic