idrassi / DirHash

Windows command line utility to compute hash of directories and files
BSD 3-Clause "New" or "Revised" License
111 stars 11 forks source link

FEATURE: Use multiple hash algorithms #20

Closed david-bakin closed 1 year ago

david-bakin commented 3 years ago

(Just started using dirhash when making backups of lots of VHDs, their split archives, their par2 files, etc. and it is invaluable at catching occasional errors writing to external USB drives ... thank you! I like the flexibility - both hash and verify, choice of hash algorithm, etc.)

I'd like to be able to specify multiple hash algorithms, e.g., both BLAKE3 and SHA256. Because it may happen that when I'm comparing hash values against that provided by some source, in some cases they may specify SHA256 or MD5 or something, while for my own purposes (validating backups to external USB drives) I prefer to use something else - e.g., BLAKE3 - consistently.

If implemented as a feature I'd also suggest writing the hash values to the output file in the order specified on the command line.

Reason this might be nice is that the bottleneck is most often device input speeds - especially when talking to external drives (even at USB 3.0 speeds). CPU load is pretty minimal - at least when using -mscrypto: I can run multiple dirhashes on different (SSD but not NVMe) drives with them maxing out on read speed while my CPU load is below 30%, on a 4yr old 4core laptop. So it would be nice to be able to read a terabyte or so off the drive only once even though getting multiple hashes computed.

idrassi commented 3 years ago

Thank you for proposing this feature. It is interesting indeed to be able to compute different hashes for the same input in one call.

In order to keep the new syntax compatible with existing one, I'm thinking of making HashAlgo argument accept combination of hash algorithms in the form of ALGO1-ALGO2..-ALGOn. For example, one could specify sha1 or sha256-sha512 or md5+sha256+blake3.

For the output file, there are two cases:

I will update this issue with the progress on this idea.

idrassi commented 1 year ago

Finally I have implemented this feature, see commit: https://github.com/idrassi/DirHash/commit/3c739ee894d7111f7201434cce7b9b963da2a582 I will publish version 1.24 that includes this feature later today.