File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Random string generation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Random string generation" Watch "Random string generation" New topic
Author

Random string generation

Anna Hays
Ranch Hand

Joined: Nov 09, 2003
Posts: 131
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

Joined: Jun 09, 2003
Posts: 4632
This might be one way

Steve Deadsea
Ranch Hand

Joined: Dec 03, 2001
Posts: 125
I wrote libraries for doing this:
http://ostermiller.org/utils/RandPass.html
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
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.


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Ian Darwin
author
Ranch Hand

Joined: Aug 03, 2001
Posts: 64
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 ]

Ian Darwin
Many questions are answered in my Java Cookbook, 2nd Edition
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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".


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
 
 
subject: Random string generation
 
Similar Threads
Generating Random Number
Unique Random Number Generator : Please suggest improvements to this code
random password generation
Creating a Unique ID from a String.
random number generation