jessek / hashdeep

Other
694 stars 130 forks source link

Hash portions of a file #345

Closed xuanngo2001 closed 8 years ago

xuanngo2001 commented 8 years ago

Can hashdeep or md5deep hash portions of a file?

I copied terabytes of files and now I want to check the integrity of them. However, I don't want to hash the whole file but portions of it. Otherwise, it would take a lot of time.

For example, break the file in 5 portions and hash the last 1000 bytes of each portion.

simsong commented 8 years ago

Hi. Precisely why are you checking them for integrity? What is your failure model? If you are worried about something like an off-track write, then you need to hash the entire file, because there is an equal probability that any block may have been overwritten.

More generally, if you want to check the file integrity, then you really need to read every byte to do so. Otherwise you aren't checking the file's integrity, you are just checking the integrity of a small portion.

jessek commented 8 years ago

The easiest way to hash a portion of a file is to use another utility to read the file and then pipe that into hashdeep. For example:

$ dd bs=10485760 skip=10000000 count=10 FILE | hashdeep