I'm trying to develop a program that convert 6 bytes into a hexadecimal representation (like 00:65:36:21:A5:BC)
with this method :
public static String toHexString(byte[] bytes) {
StringBuilder sb = new StringBuilder(18);
for (byte b : bytes) {
if (sb.length() > 0)
sb.append(':');
sb.append(String.format("%02x", b));
}
return sb.toString();
}
I'm obtaining a good format, but now I have to reverse the digits two by two.
what I obtain 00:65:36:21:A5:BC
what I should get BC:A5:21:36:65:00
Can anybody help me on that final step ?? I'm struggling to take each pair of digits and reverse its position (putting BC at the beginning, but without changing its order (like CB)
Thanks in advance
G.
bytes? Or even to iteratebytesin the opposite direction?