The goal, based on a sort of principle of locality (or just the typical way checkfiles are generated), is to improve real-world performance by inferring the correct hash algorithm based on previous successes in the same run. I imagine in most cases there will be exactly one successful algorithm per checkfile, but this implementation supports arbitrarily many.
I've tried to make the minimal changes to the existing code necessary to achieve this; integrating in that way always makes the code feel potentially a little messy to me, but it also seems the most friendly way to offer changes. I tried to preserve the existing style even when it didn't match my own. Because of the bitwise markers used to manage the hash-check routines in the existing code, I didn't see an immediately obvious cleaner way to perform the kind of "caching" I wanted to perform.
I'm not sure if anyone needs this, but the use case I have in mind is a checkfile generated in the typical way by rhash or a program that supports a singular algorithm (sha512sum or whatever). Run over large files or many files, it is potentially quite wasteful to walk through every algorithm for a particular size of a message digest.
The goal, based on a sort of principle of locality (or just the typical way checkfiles are generated), is to improve real-world performance by inferring the correct hash algorithm based on previous successes in the same run. I imagine in most cases there will be exactly one successful algorithm per checkfile, but this implementation supports arbitrarily many.
I've tried to make the minimal changes to the existing code necessary to achieve this; integrating in that way always makes the code feel potentially a little messy to me, but it also seems the most friendly way to offer changes. I tried to preserve the existing style even when it didn't match my own. Because of the bitwise markers used to manage the hash-check routines in the existing code, I didn't see an immediately obvious cleaner way to perform the kind of "caching" I wanted to perform.
I'm not sure if anyone needs this, but the use case I have in mind is a checkfile generated in the typical way by rhash or a program that supports a singular algorithm (sha512sum or whatever). Run over large files or many files, it is potentially quite wasteful to walk through every algorithm for a particular size of a message digest.
See also https://github.com/rhash/RHash/issues/256.