如题。我需要实现一个类似于Hex Comparison这样的工具。Hex的实现不成问题,就是想知道如何实现两个二进制文件的对比?不需要合并只需要对比。 有现成的轮子可以让我直接调用然后得到两个文件的差异吗?
大家讲道理2017-04-17 13:50:28
Provide several methods for reference:
Using the diff/cmp
command on the command line, you can determine whether the two binaries are exactly the same:
diff file1 file2
cmp -b file1 file2
hexdump
under the command line, after getting the hex text, use diff to compare the hex text of the two files:
hexdump file1.bin > file1.hex
hexdump file2.bin > file2.hex
diff file1.hex file2.hex
Calculate the MD5 or SHA1 of these two files. If the hash values obtained are the same, they are the same file