The many flavors of hashing
notes.volution.ro
notes.volution.ro
> Related to the "looks random enough" aspect, because the input size is almost always larger than the output (which is fixed size), there are usually an infinite number of inputs for which the output is the same, thus these functions are not surjective.
The word you are looking for here is "injective", not "surjective".
Edit: As long as I'm pointing out wrong-word errors like this, I should probably also point out that the phrase is "bear with me", not "bare with me".
Sur- means 'upon' (sorta) as in sur-la-table, so we know the surjective is upon the entire codomain, hence surjective is the 'at least once' class, leaving injective as the 'at most once' class.
Bijective is the invertible one but I've never had problems remembering that and I note that you don't mention it either.
https://www.cs.ucdavis.edu/~rogaway/papers/thorp.pdf
(You do not need to limit yourself to inputs that are multiples of the AES block size).
There's another one like this, I forget the name.
SHA-2 is just fine, and is usually a saner choice than SHA-3 (if you want to be a crypto-hipster, use Blake2, not SHA-3; it's usually an easier dep to pull in, and more things use it).
For example even in the case you've described "where you want to guarantee nobody could force a collision" my suggestion is to use a keyed algorithm (like Blake3) or a HMAC and choose a different key (if not for each "instance" algorithmically tied to it, at least for each "deployment"). It doesn't solve the brute force, but it might save you from other mistakes related to how you use those hashes (like for example when the attacker might swap or replace two payloads with their hashes).
I published my implementation in the Pseudorandom Permutations section of my "Correlated Multi-Jittered Sampling" tech report: https://graphics.pixar.com/library/MultiJitteredSampling/pap...