I have a Base64 String, which is 'AAAC', which in binary is equivalent to 3 bytes (00000000 00000000 00000010).
I would like to convert 'AAAC' to a ASCII Hex Byte String to output something like '000002'.
I have tried below.
byte[] test = Base64.decode(data.getBytes());
StringBuilder sb = new StringBuilder();
for (byte b : test) {
sb.append(String.format("%02X ", b));
}
System.out.println(sb.toString());
//Output: 00 00 02
This works, but is there a more effient way to do this?
Any help would be appreciated. Thanks in advance.