Created
June 4, 2018 22:46
-
-
Save phoddie/647df056c10443cb7e1413f8df1ee736 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tracePacket(bytes) | |
{ | |
for (let i = 0; i < bytes.length; i += 16) { | |
let end = i + 16; | |
if (end > bytes.length) end = bytes.length; | |
for (let j = i; j < end; j++) { | |
let byte = bytes[j].toString(16); | |
if (byte.length < 2) byte = "0" + byte; | |
trace(byte, " "); | |
} | |
trace(" "); | |
for (let j = i; j < end; j++) { | |
let byte = bytes[j]; | |
if ((32 <= byte) && (byte < 128)) | |
trace(String.fromCharCode(byte)); | |
else | |
trace("."); | |
} | |
trace("\n"); | |
} | |
trace("\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment