# “perfect” hash function [closed]

Does there exist any hashing function that has a different output for all of the messages?

For example, let's say we have the function $$H_{256}(x)$$

Where $$H$$ is a 256 bit digest. Is it possible to construct $$H$$ so that it has a different output for every combination from $$0$$ to $$(2^{256}-1)$$?

EDIT: what I mean is, if you have a hash function which produces a fixed length 256 bit digest, is it possible to make such function so that every permutation of 1's and 0's of length 256 have a different output? I hope I'm clear now

• That is a permutation. Use AES and you have it. If you want 256 use Rijndael. – kelalaka Oct 25 '19 at 16:30
• @kelalaka, the other problem is that AES has a key. What do you use for a key? Hash functions themselves do not have secret values, so the key must be known to all, so for any message of just a single block, you could decrypt to get the original. – mikeazo Oct 25 '19 at 16:35
• Here's one: $H(x) := x$. But maybe you want some security properties other than distinctness for all inputs? Why do you need it to be actually injective, rather than merely (say) preimage-resistant? – Squeamish Ossifrage Oct 25 '19 at 16:40
• @mikeazo you can fix the key. Anyway, the question title is also misleading. Maybe the op needs UUID if he has some aim. – kelalaka Oct 25 '19 at 17:03
• Isn't the answer simply "Unknown." since we can't prove that a hash function like SHA-2 will / won't have any collisions? – AleksanderRas Oct 25 '19 at 17:04