This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Generate next hexadecimal? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Generate next hexadecimal?" Watch "Generate next hexadecimal?" New topic
Author

Generate next hexadecimal?

Sylvia Allen
Greenhorn

Joined: Apr 02, 2001
Posts: 18
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


Sylvia Allen<br />sylviaa53@yahoo.com
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
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.


Rob
SCJP 1.4
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
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.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
 
 
subject: Generate next hexadecimal?
 
Similar Threads
Identify whether the string is a actual string or hexadecimal.
Another Ques from abhilash's site
hexadecimal numbers
Difficulty of shift operator and hex conversion
Hexadecimal to String and vis versa