Skip to content

Instantly share code, notes, and snippets.

@typelogic
Created December 19, 2019 16:16
Show Gist options
  • Select an option

  • Save typelogic/65d4708db7f91d55429d7c9b9d27d17c to your computer and use it in GitHub Desktop.

Select an option

Save typelogic/65d4708db7f91d55429d7c9b9d27d17c to your computer and use it in GitHub Desktop.
java hexdump
public static void prettyOut(byte[] msg) {
for (int j = 1; j < msg.length+1; j++) {
if (j % 32 == 1 || j == 0) {
if( j != 0){
System.out.println();
}
System.out.format("0%d\t|\t", j / 8);
}
System.out.format("%02X", msg[j-1]);
if (j % 8 == 0) {
System.out.print(" ");
}
}
System.out.println();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment