This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generate next hexadecimal?

 
Sylvia Allen
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I imagine this is a really dumb question, but is there some standard simple code for generating the next largest number in hexadecimal format? I need to generate sequential alphanumeric passwords. There must be some standard simple way to do this.
- SA
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you asking how to format an integer as a hex value? If so, just use the Integer wrapper class and call the static method toHexString(). That will take an int, and return a String formatted in hex notation.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sylvia Allen:
I need to generate sequential alphanumeric passwords. There must be some standard simple way to do this.
- SA

I found the easiest way was to just create an array of all the acceptable characters in the password:
char[] passChars = {'A', 'a', ..... '9'};
Then just generate random numbers that range from 0 to 1 less than the length of the array and use that as an index into the array. Need a password of 8 characters? Generate 8 random numbers and pull 8 random characters from your array.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic