• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to generate key from string

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i want to generate a password or a key on the basis of any string .could any one tell me how should i can do this, and what API to use .
thanks !!
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm, what is the requirement around "based on a string"? I'm not sure how to use that.
You could use random numbers to generate gibberish. I sometimes use a string of the alphabet plus digits 0-9 to get 36 characters, then pick 8 out of there at random. You might leave out the vowels to avoid accidental racy words or confusion between I-1 or 0-O. I once loaded a dictionary of words and used two words chosen at random for passwords like "WATER BOLDLY". That was actually my CompuServe password 20 years ago. Words seem to be easy to remember.
Back to that "based on a string". I guess you could get the hashcode for the string and use it for a seed to the random number generator. The same string would get you the same random numbers every time.
Any of those jump out as something you could use?
 
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
another approach,
put characters of the string into a list, then use
Collections.shuffle(list) from java.util to randomize the list.

Originally posted by richa patel:
hi,
i want to generate a password or a key on the basis of any string .could any one tell me how should i can do this, and what API to use .
thanks !!

 
reply
    Bookmark Topic Watch Topic
  • New Topic