How to efficiently identify a binary file

后端 未结 4 1949
醉梦人生
醉梦人生 2021-02-10 19:36

What\'s the most efficient way to identify a binary file? I would like to extract some kind of signature from a binary file and use it to compare it with others.

The bru

4条回答
  •  甜味超标
    2021-02-10 20:10

    That's what hashing is for. See MessageDigest.

    Note that if your file is too big to be read in memory, that's OK because you can feed chunks of the file to the hash function. MD5 and SHA1 for example can take blocks of 512 bits.

    Also, two files with the same hash aren't necessarily identical (it's very rare that they aren't though), but two files that are identical have necessarily the same hash.

提交回复
热议问题