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
posted
0
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
posted
0
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.