Home > Enterprise >  Unhashing strings C
Unhashing strings C

Time:05-20

I know of the std class std::hash and have hashed values of a vector by using it. But I can't find any documentation or other std classes on unhashing the hashed values.

Can anybody point me in the correct direction of a class that can unhash the hashed strings?

Any help is greatly appreciated!

CodePudding user response:

Hashing is a process which destroys parts of the information. There is no way to "unhash" something reliabily.

A very simple string hashing algorithm might help you understand better. A very simple (and usually not very good) hashing algorithm for strings is just to sum up all the characters. So you get something like 435 as the hash. This hash contains no more information about the original string, other than the fact that sum of all the bytes that made up the string is 435.

CodePudding user response:

No, you can't.
Just simple, imagine hash function as addition, let's hash these:

  1. {5,2} -> 5 2=7
  2. {3,4} -> 3 4=7
  3. {6,1} -> 6 1=7

there are countless ways of making 7.
Now, I say let's un-hash "7", we can't.

  • Related