For the purpose of fingerprinting data with the least chance of collision will combining the length (as a 32 bit unsigned integer stored in addition to the hash) of the input data and/or sampling a few bytes from the input significantly strengthen the resulting output combined with the hash?
For example:
sha256(data) + length + first_2_bytes_of_data = 304 bits
Note: (updated)
- The privacy of the input data is not paramount, more the ability to detect if the data has changed.
- Also I use a 256 bit hash function in this example but the question is less about the final choice of hash function and more about will adding the 6 extra bytes help.
- The length in bytes of the input data will always be variable but always less than or equal to 2 to the power of 32.
- The resulting output will be used both for integrity verification and as a dictionary key for up to 2^64 items (if key collision is considered unpractical or impossible)
