Is SHA (-1-2-3) a one-to-one function for inputs of the same length as the output?
Is SHA (-1-2-3) a one-to-one function for inputs of the same length as the output?
To repeat the question as a concrete example: SHA-1 has 160 byte outputs, so all 160 byte inputs have unique 160 byte outputs? Is the answer the same for SHA-2 and 3 and for all available output sizes?
source to share
Nobody knows, because nobody has proven it anyway, or tested every possible input in this range. This is the simple truth.
If the functions were behaving in a truly random manner, then the answer would almost certainly be no due to the birthday paradox - on average you need to test 2 ^ 80 inputs to find a collision between any pair, for 160 bits.
source to share
Short answer: While there is no definitive definitive answer, I think the safer bet (if you are extending your question to cover all of the SHA family's features) is to say no . Let's get a little more mathematically.
Let's pick and examine one of the SHA family functions. Suppose it returns n-bit output and behaves like a "random oracle" (it doesn't, but suppose), which means it will return a random n-bit value for any constrained input that will always return the same output for the same entrance.
Under these assumptions, the probability of collision for any two input strings that do not match should be 2 ^ (- n). Due to the paradox of the day, you would expect to find a collision after about 2 ^ (n / 2) different entries.
So, due to the paradoxical birthday, the likelihood that our function will be one-to-one when hashing n-bit inputs and generating n-bit outputs is not very good.
Ultimately, the only way to definitively answer your question is to try all possible n-bit inputs with all possible n-bit SHA functions. Don't count on getting a definitive answer in your life ...
source to share