Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_java thread: How do I undo the Hashcode value


Message #1 by hellen_76@h... on Thu, 8 Aug 2002 04:53:21
No, there is no way to un-hashcode to a String value. The hashcode values 
returned by the hashCode() method are intended to provide a broad spread 
of values for use when storing Strings in hash containers, but they are 
not really suitable for password encryption. Two different Strings can 
give the same hashcode.

In most simple password verification schemes, for security the password is 
stored encoded with a one-way encryption algorithm so that it cannot be 
decoded. When comparison is required, the password to be validated is 
encrypted with the same algorithm and the two encoded values are compared. 
This means the password is relatively secure - once encrypted there is no 
way it can be decoded, and the system only holds the encrypted version.  

You might want to look at the MessageDigest class in java.security, which 
has functions that will give you a one-way hash value more suitable for 
password storage.

> hi,
 >    Before I store a password into the database, I've got the hashcode 
v> alue of the password String using the My_String.hashCode() method of 
the 
S> tring class. Is there anyway to un-hashCode this value back to the 
o> riginal String when I retrieve it form the database? 
T> hanks.

  Return to Index