This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of TensorFlow 2.0 in Action and have Thushan Ganegedara on-line!
See this thread for details.
Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Random string generation

 
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.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This might be one way

 
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
 
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.
 
author
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 ]
 
(instanceof Sidekick)
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".
 
It will give me the powers of the gods. Not bad for a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic