The checksum and hash are basically the same. You should be able to calculate any hash. Usually normal MD5 is enough. If you want, you can keep the size and hash of md5 (I think it's 16 bytes).
If two files have different sizes, these are different files. You do not even need to calculate the hash from the data. If it is unlikely that you have a lot of duplicate files, and the files have a larger look (for example, JPG images taken with the camera), this optimization can save you a lot of time.
If two or more files are the same size, you can calculate the hashes and compare them.
If the two hashes are the same, you can compare the actual data to make sure it is all the same. This is very, very unlikely, but theoretically possible. The larger your hash (md5 is 16 bytes, and CR32 is only 4), the less likely it is that two different files will have the same hash. It only takes 10 minutes of programming to complete this additional check, so I would say: it's better safe than sorry. :)
To optimize this, if exactly two files are the same size, you can simply compare their data. You still need to read the files to calculate their hashes, so why not compare them directly if they are the only two with this particular size.
Goleztrol
source share