-3

Imagine a theoretical universe where reverse hashing is possible. What if I take a 5000 bit message and hash it. So now I get a hashed string of say 256 bits. If I can get back to the 5000 bit message(theoretically) wouldn't I achieve the Holy Grail of compression? Like I can take any string in the world and compress it to something very small...

3
  • 3
    Imagine a theoretical universe ... - why? It's purely theoretical. Hashes are algorithms with information loss so it is practically impossible what you imagine. May 29, 2017 at 6:59
  • 4
    If you would be able to do that, you would have an infinite compression algorithm. Have a look at the internals of a hashing algorithm and you will understand better. May 29, 2017 at 7:14
  • 1
    There is a lot of math behind of hashes. But its primary purpose, why they were designed, is the impossibility of reversing the original data back from the hash. Just keep it as it is. Hash is used to fingerprint the data, not to compress them. And in short, if I would use 2 bit hash I can have just 4 fingerprints for any kind of the data. In this case you can see the probability of collision is quiet high and it does not matter what algorythm I'll use. Also, as you can see, from 4 bits I can't reconstruct 100MB file...
    – Fis
    May 29, 2017 at 10:30

1 Answer 1

4

The problems are collisions. Due to the fact that hashes have limited different outputs one can not know what exact value was hashed. Yeah, you can guess, but you will not get the correct value 100% of the time (except you have a limited set of values from which you know that they do not have collisions). Just think of a situation where hash(I will donate you 1000$) = hash(You owe me 1000$). That would cause some serious problems in communication. So collisions are the reason why you should not use hashes for compression.

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