This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am using the String method hashCode() to obtain the hash value of a specified String. I need to to convert the hash value back to the original String. Can anybody help? Essentialy this should be simple but I am stumped!
Originally posted by Anthony Alberts: I am using the String method hashCode() to obtain the hash value of a specified String. I need to to convert the hash value back to the original String. Can anybody help? Essentialy this should be simple but I am stumped!
It's not only not simple, it's impossible! First, there is no guarantee that two different Strings also differ in their hashcode. In fact there *have* to be Strings which are not equal but share the same hashcode - after all, there are much more possible values for a String than possible values for an int! Second, there is no guarantee on how the hashcode of a String is calculated, afaik - the algorithm might very well differ strongly between JRE implementations.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: Sep 18, 2001
Thanks for that. I assume then that my understanding of Hash leaves much to be desired or possibly smo'kn too much of the above.