I am trying to get back a string from its hash value?
string str="Hello";
int hashStr=str.GetHashCode(); // hash value of "Hello" is -694847
can I get back my_string (i.e “Hello”) form the hashed value….?
UPDATED
actually i am thinking to save password into my database after hashing to make it secure…
So it means a different password even have same value?
There are exactly 2^32 many hash codes but way, way more
strings. Thus, by the pigeonhole principle, there have to be multiplestrings mapping to the same hash code. Therefore, an inverse map from hash code tostringis impossibleEdit: Response to your update.
Yes, it is possible for two passwords to have the same hash. This is basically a restatement of the above. But you shouldn’t use
GetHashCodeto hash the password. Instead, use something secure like SHA-2.To go one step further, never try to roll your own your encryption/security etc. Find a library that does it for you.