binary file hexdump

Sometimes you need to quickly create a hexeditor like dump of a binary file. HEXDUMP is your friend. It may be a standard Unix application or Python module.

Unix hexdump use example:

hexdump -Cv file.bin
00000000  12 01 00 02 ef 02 01 40  28 0d 04 02 00 10 01 02  |.......@(.......|
00000010  03 01 12 01 00 02 ef 02  01 40 28 0d 04 02 00 10  |.........@(.....|
00000020  01 02 03 01 09 02 82 00  04 01 00 80 fa 09 02 82  |................|
00000030  00 04 01 00 80 fa 09 04  00 00 02 08 06 50 07 07  |.............P..|
00000040  05 82 02 40 00 00 07 05  02 02 40 00 00 09 04 03  |...@......@.....|
00000050  00 02 03 00 00 06 09 21  00 01 00 01 22 21 00 07  |.......!...."!..|
00000060  05 81 03 40 00 01 07 05  01 03 40 00 01 08 0b 01  |...@......@.....|
00000070  02 02 02 01 04 09 04 01  00 01 02 02 01 04 05 24  |...............$|
00000080  00 10 01 05 24 01 03 02  04 24 02 06 05 24 06 01  |....$....$...$..|
00000090  02 07 05 83 03 10 00 20  09 04 02 00 02 0a 00 00  |....... ........|
(...)

Python hexdump use example:

python -m pip install hexdump
python -m hexdump file.bin
00000000: 12 01 00 02 EF 02 01 40  28 0D 04 02 00 10 01 02  .......@(.......
00000010: 03 01 12 01 00 02 EF 02  01 40 28 0D 04 02 00 10  .........@(.....
00000020: 01 02 03 01 09 02 82 00  04 01 00 80 FA 09 02 82  ................
00000030: 00 04 01 00 80 FA 09 04  00 00 02 08 06 50 07 07  .............P..
00000040: 05 82 02 40 00 00 07 05  02 02 40 00 00 09 04 03  ...@......@.....
00000050: 00 02 03 00 00 06 09 21  00 01 00 01 22 21 00 07  .......!...."!..
00000060: 05 81 03 40 00 01 07 05  01 03 40 00 01 08 0B 01  ...@......@.....
00000070: 02 02 02 01 04 09 04 01  00 01 02 02 01 04 05 24  ...............$
00000080: 00 10 01 05 24 01 03 02  04 24 02 06 05 24 06 01  ....$....$...$..
00000090: 02 07 05 83 03 10 00 20  09 04 02 00 02 0A 00 00  ....... ........
(...)