
On 12/8/24 21:31, Peter Dimov via Boost wrote:
So, for example, if you have a 32 bit hash function and you need 64 bits, this is how you would do it, ordered from best to worst:
// as good as possible uint64_t f1( Hash& hash ) { uint32_t r1 = hash.result(); uint32_t r2 = hash.result(); return (uint64_t(r1) << 32) | r2; }
// not that bad, but worse than the above uint64_t f2( Hash& hash ) { return get_integral_result
( hash.result() ); } All that leads me to the thought that I've got get_integral_result wrong; it should take the hash algorithm directly, not its result, and should invoke result() as many times as needed to obtain the necessary number of bits.
This would be incompatible with algorithms that don't support multiple calls to finalize().