H
Henry Townsend
What's the most efficient/elegant way to represent an MD5 in base 36?
Here's some code I've cribbed together from MD5 samples but this is
converting byte-by-byte to base 16 then on to base 36, which seems dumb.
But I'm kind of lost in all the different constructors and static
methods offered by Byte, String, Long, etc.
byte[] digest = md.digest();
StringBuffer hex = new StringBuffer();
for (byte b : digest) {
hex.append(Integer.toHexString(b & 0xff));
}
String base36 = new BigInteger(hex.toString(), 16).toString(36);
Thanks,
HT
Here's some code I've cribbed together from MD5 samples but this is
converting byte-by-byte to base 16 then on to base 36, which seems dumb.
But I'm kind of lost in all the different constructors and static
methods offered by Byte, String, Long, etc.
byte[] digest = md.digest();
StringBuffer hex = new StringBuffer();
for (byte b : digest) {
hex.append(Integer.toHexString(b & 0xff));
}
String base36 = new BigInteger(hex.toString(), 16).toString(36);
Thanks,
HT