File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes converting a byte array to hex values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "converting a byte array to hex values" Watch "converting a byte array to hex values" New topic
Author

converting a byte array to hex values

shawn_ayers
Greenhorn

Joined: Jan 02, 2001
Posts: 2
I am experimenting with BASE64/MD5 and would like to convert a byte array into their corresponding hex values. Any ideas how I can accomplish this?
Thanks,
Mark Savory
Ranch Hand

Joined: Feb 08, 2001
Posts: 122
Try,
byte b = 65;
Byte bite = new Byte(b);
String hex = Integer.toHexString(bite.intValue());
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
"shawn_ayers",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements.
Thanks.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
And be aware that converting characters to and from their hex codes is not base64, that's the encoding scheme used by uuencode.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: converting a byte array to hex values