Are all or any hash functions evenly distributed?

For example: if you had every combination of 256 bits and ran that through SHA256, would that produce approximately 1 of each combination, or would there be peaks?

Are distributions of the hashes calculable without going through the permutations in lower bit sizes?

Is evenness of the distribution of a hash function impacted by the length of the input vs the resultant hash length?

Which hashing functions are most evenly distributed? (e.g. as close to 1 of each equal-bit-length combination possible)

Edit: The linked "duplicate" doesn't come close to addressing all these questions.


https://crypto.stackexchange.com/a/12511/23115 gives the answer regarding uniformity. If you stick to the 256 bit input however, you will only get $ 1-\frac{1} {e} $ of the possible outputs. This is due to the hash acting as a pseudo random function and collisions occurring. This behaviour can also be called surjective.

| improve this answer | |
  • $\begingroup$ Wow, that was fast! $\endgroup$ – Paul Uszak Mar 15 '19 at 0:27
  • 7
    $\begingroup$ That's not what surjective means. $\endgroup$ – Squeamish Ossifrage Mar 15 '19 at 0:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.