How to create a hexdump and convert back?

The format of hexdump makes its possible to convert any types of files into plain text, which would simply your file transfer in some cases. How can we make a hexdump from a given file? Well, with the help of a common tool ‘xxd‘, it’s quite easy.

xxd is part of vim-common in Linux distributions, and available in Mac OS X as well,

$ rpm -qf /usr/bin/xxd
vim-common-7.0.109-7.el5

To convert a file to hexdump,

$xxd -p /etc/passwd

To convert hexdump to its original format,

$ xxd -r -p file.hex.dump

This command will not bring any additional chars,

joseph$ cat /etc/passwd | md5
5e7f80888f3d491c4963881364048c24
joseph$ xxd -p /etc/passwd | xxd -r -p | md5
5e7f80888f3d491c4963881364048c24

Other tools you can refer to are hexdump, od, etc.

Share Button

Leave a comment

Your email address will not be published. Required fields are marked *