A simple hex dump utility in Go, inspired by the Unix xxd command, capable of generating hex dumps and reversing them back to the original binary. Works for text, PDFs, images, and other binary files.
-
Hex dump of any file: Converts a file into a human-readable hex format.
-
Reverse mode (
-r): Converts a hex dump back to the original file. -
Custom output file: Specify the output filename with
-o. -
Default behavior:
- Hex dump: adds
.hexextension to the input file if-ois not specified. - Reverse mode: removes
.hexfrom input filename; otherwise prependsrecovered_.
- Hex dump: adds
-
Supports binary files: Safely handles PDFs, images, and other non-text files.
-
Portable: Saves outputs in the current folder.
Make sure you have Go installed. Clone or copy the xxd.go file.
git clone https://github.com/dunstanad/go-xxd-tool.git
cd go-xxdgo run xxd.go myfile.pdf- Output:
myfile.pdf.hex - Hex dump saved in the current folder.
go run xxd.go -o dump.hex myfile.pdf- Output:
dump.hex - Works for any file type.
go run xxd.go -r dump.hex- Strips
.hexfrom filename: outputdump - Works for binary files, but you may need to manually add the extension (e.g.,
.pdf,.jpg) if the original extension is required.
go run xxd.go -r -o recovered.pdf dump.hex- Output:
recovered.pdf - Recommended for binary files to ensure correct file type.
For binary files (PDFs, images, etc.), always specify the correct output filename with extension in reverse mode using -o. Otherwise, the restored file may not have the proper extension, even though the contents are correct.
- Create hex dump (default):
go run xxd.go -o linux.hex linux-commands.pdf- Reverse hex dump with custom output:
go run xxd.go -r -o linux.pdf linux.hexThis project is licensed under the MIT License.



