Oct 13
You have a couple of choices, either:
- Loop thru the array to convert each byte individually, or
- Use the toString() method of the BigInteger class
// using a loop
StringBuilder sb =
new StringBuilder(bytes.length * 2);
for (int i=0; i< bytes.length; i++)
{
sb.append(String.format("%02x", bytes[i]));
}
String hex1 = sb.toString();
// using BigInteger
BigInteger bi = new BigInteger(bytes);
String hex2 = bi.toString(16);
Leave a Reply
You must be logged in to post a comment.