4 FAQ
xfarrow edited this page 2023-05-18 08:25:08 +00:00

Standard file comparison VS hash file comparison

When checking whether two files are equal or not, by default dircomp compares their content (in bytes). By enabling option -d dircomp compares the SHA-1 hash of the files.

As anyone can guess, a direct comparison is faster than computing an hash (which requires the files to be fully read anyways) plus comparing the result of said hash, so why creating this functionality in the first place?

  • If one wants to be extra sure of the correctness of the output of this program, they may execute two different comparisons. This can be understandable since this program is not wide-spread so there might occur edge cases the developer has never considerated;
  • I'd like to implement more functionalities which require a digest computation. I already had the knowledge to compute the SHA-1 of a file so I decided to insert the relative functions in the source already.
  • Perhaps one could be interested in obtaining the hash of the files that are being processed. This is not supported, but they'd be few lines away from obtaining what they need.