Share your repls and programming experiences

← Back to all posts
Hex Dumping Tool
ANDREWVOSS (187)

What it Does

This program works almost exactly like xxd (but without all the command-line options). The main differences being that it groups the hex by bytes rather than double-bytes, and it outputs decoded text line by line rather than one character at a time.

How it works

The program first opens a file, and loads it into memory as an array of bytes. Then, it visually displays each byte one by one, and decoding each byte as it is displayed. If the decoded byte is a safe ASCII character, it appends it to a string. Otherwise, it appends a .. Every 16 bytes, the string is displayed and then reset for the next 16 bytes. After the file is done displaying, the program checks if there are any bytes left in the string, and displays the string if there are any.


If you read this far, thank you! I know this post was a little more more long-winded than usual (and with a little less markdown), so it may have been boring to read, but I really enjoyed making this.