This makes it possible to register hasher factories that take a size hint. Such hashers should produce at least the requested number of bytes, but may:
Produce fewer bytes in some cases (e.g., not enough input is available).
May produce more bytes (the usual case).
The caller should check the size of the produced digest to determine if it's sufficient for the caller's use-case (likely truncating it if it's too large).
NOTE: the convenience Sum function will handle size verification and truncation internally.
TODO:
Add tests.
Audit documentation.
Audit errors.
I'm posting this as a "here's how to do it", but someone else will have to take it to completion if we want to merge this.
This makes it possible to register hasher factories that take a size hint. Such hashers should produce at least the requested number of bytes, but may:
The caller should check the size of the produced digest to determine if it's sufficient for the caller's use-case (likely truncating it if it's too large).
NOTE: the convenience
Sum
function will handle size verification and truncation internally.TODO:
I'm posting this as a "here's how to do it", but someone else will have to take it to completion if we want to merge this.