How to compare binary files to check if they are the same?
Solution 1:
The standard unix diff
will show if the files are the same or not:
[me@host ~]$ diff 1.bin 2.bin
Binary files 1.bin and 2.bin differ
If there is no output from the command, it means that the files have no differences.
Solution 2:
Use cmp
command. This will either exit cleanly if they are binary equal, or it will print out where the first difference occurs and exit.
Solution 3:
I found Visual Binary Diff was what I was looking for, available on:
-
Ubuntu:
sudo apt install vbindiff
-
Arch Linux:
sudo pacman -S vbindiff
-
Mac OS X via MacPorts:
port install vbindiff
-
Mac OS X via Homebrew:
brew install vbindiff
Solution 4:
Use sha1 to generate checksum:
sha1 [FILENAME1]
sha1 [FILENAME2]
Solution 5:
I ended up using hexdump to convert the binary files to there hex representation and then opened them in meld / kompare / any other diff tool. Unlike you I was after the differences in the files.
hexdump tmp/Circle_24.png > tmp/hex1.txt
hexdump /tmp/Circle_24.png > tmp/hex2.txt
meld tmp/hex1.txt tmp/hex2.txt