• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

converting a byte array to hex values

 
shawn_ayers
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try,
byte b = 65;
Byte bite = new Byte(b);
String hex = Integer.toHexString(bite.intValue());
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And be aware that converting characters to and from their hex codes is not base64, that's the encoding scheme used by uuencode.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic