Hexdump Utility

3.3 · maintenance · verified Wed Apr 15

The `hexdump` Python library (version 3.3) provides functionality to dump binary data into a human-readable hexadecimal format and to restore binary data from such hex dumps. It works across Linux, Windows, and OS X, serving as both a Python library and a command-line tool. The last official release was in January 2016, indicating a maintenance phase rather than active development, though it remains functional for its stated purpose.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `hexdump.hexdump()` to print a hexadecimal representation of binary data to standard output, and `hexdump.dehex()` to convert a hexadecimal string back into binary data. It also shows how to use `hexdump.dumpgen()` to get the hexdump as an iterable of strings for more control over output.

import hexdump

# Dump bytes to hex string, output to stdout
data_to_dump = b"Hello, hexdump library! This is some binary data to inspect."
print("\n--- Hex dump of data ---")
hexdump.hexdump(data_to_dump)

# Restore binary data from a hex string
hex_string_to_restore = "48 65 6C 6C 6F 2C 20 68 65 78 64 75 6D 70 20 6C 69 62 72 61 72 79 21 20 54 68 69 73 20 69 73 20 73 6F 6D 65 20 62 69 6E 61 72 79 20 64 61 74 61 20 74 6F 20 69 6E 73 70 65 63 74 2E"
restored_data = hexdump.dehex(hex_string_to_restore)
print("\n--- Restored data ---")
print(restored_data)

# You can also get the hexdump as a string instead of printing directly
hex_lines = []
for line in hexdump.dumpgen(data_to_dump):
    hex_lines.append(line)
print("\n--- Hex dump as list of strings ---")
print("\n".join(hex_lines))

view raw JSON →