Background
In theory, hash functions produce a binary number having bounded (often fixed) length from binary data of arbitrary length.
In practice, specifications and implementations constrain the input length to be a multiple of 8. This is reasonable because, in practice, the binary data that clients hash is represented in chunks of bytes (not bits).
Suppose that we want to use hash algorithms in a context that cannot assume the input binary data is chunked into bytes.
For example, we want to compute a hash for a 13-bit data stream
0101111101111
.
Further, assume that the value intended by any binary fragment of a length indivisible by 8 is unambiguously distinct from any padded byte-divisible representation.
For example, our system requires that the 13-bit
0101111101111
means something fundamentally different from any 16-bit value (such as the left-padded0000101111101111
or right-padded0101111101111000
). Consequently, their hashes should be distinct.
Question
What established hash algorithms are compatible with input binary data of arbitrary bit length?
What prior work and implementations exist that directly address this limitation of many common algorithms and libraries?
Note
I recognize that the distinction between truncated arbitrary-length binary data and padded byte-chunks could be retrofitted into byte-divisible input by tagging the padded input data with a byte-divisible representation of its truncated length. If a less redundant approach is available, it would seem preferable.