Only unique if you do not do it too often
The answer to the question becomes obvious when we give it the complete phrasing.
We know that good hashing algorithms would generate hashes that are pretty much unique, as long as we do not use on too many possible inputs.
You left out the bit that I have highlighted. That last bit is why hashes work and are "pretty much unique", but that is completely negated if you use too many different inputs. Then they are not "pretty much unique" any more but will appear many times. This is known as hash collisions.
So how bad would the collision problem be? Let us make a few assumptions.
- Assume a clear-text message of 1024 bits. With a 7-bit alphabet, this allows us to send a message slightly longer than the max length of a Twitter message.
- Assume a 256 bit hash. This corresponds to a compression ratio of 400%.
- Assume that hashes distribute themselves uniformly, that is to say that every hash has an equal probability to appear as a result.
- Assume we hash every possible message that can be sent with 1024 bits.
The issue you face here is that once you are done, every hash will appear $2^{1024-256} = 2^{768} \approx 10^{231}$ times.
The number of particles in the known observable universe is less than $ 10^{81}$
So... this is what happens:
- You receive a hash.
- You put it into you magical quantum computer.
- Your computer reverse calculates the possible inputs.
- As a result, you get more possible clear-text messages than can even fit in the observable universe.
How can you know which one was sent?
In summary: you cannot know which message was actually sent.
"But what if we..."
You object. You say:
"But I am only interested in meaningful messages, not garbage like VGhpcyBpcyBhY3R1YWxseSBhIG1lYW5pbmdmdWwgdHdlZXQ= !".
Well in that case, if you are happy with for instance limiting yourself to written English, then the number of possible messages drop significantly. According to xkcd: what if, number 34, there are about $2^{154}$ possible meaningful Twitter messages in English(1). Now the chance of collision is very small, so if you are happy with a fixed compression ratio of 400%, then things are all peachy.
But why would you settle for 400% when you can get up to 900% using plain old compression algorithms, without the need for a magical quantum computer?
"Fine!", you say! "I will decrease the side of my hash!".
So you decrease the size of the hash to 128 bits. Now you have a compression ratio of 800%. However...
$2^{154-128} = 2^{26} \approx 10^{7.8}$
...which is to say that every hash has more than 10 million possible clear-text messages... 10 million possibilities that all make some kind of sense.
And to rub salt in the wound: you are still coming up short on the data rate savings compared to plain old compression.
So in conclusion: yes, you could — hypothetically — use hashes to compress messages. But the compression rate would not be better than when using existing compression algorithms. And you would need a magical quantum computer to be able to use this method.
(1) ...precluding using words that do not appear in any dictionary, like curiously spelled names