What you're looking for is a cryptographic hashing function. There are generally two mainstream flavors: MD5 and SHA1.
http://java.sun.com/j2se/1.4.2/docs/api/java/security/MessageDigest.html http://java.sun.com/developer/technicalArticles/Security/Crypto/ Hashing functions are used to produce a unique key for some input. If the input changes in any way, then the hash produced will be completely different, however if the same input is supplied you will consistently be getting the same hash.
In UNIX, for example, passwords are not stored in cleartext. Instead, the passwords are hashed and the hash is stored. This way if a hacker gets his hands on the hash he/she has no way of getting back the password. This is a property of a one-way hash function - you can only go one way (from password to hash, and not from hash to password). When a user supplies his/her password again to login into the system, the password is hashed once again and compared to what is stored on file. If the hashes match, then you login.
Here I wrote a quick example for you:
[ July 12, 2005: Message edited by: Yevgeniy Treyvus ]
[ July 12, 2005: Message edited by: Yevgeniy Treyvus ]
[ July 12, 2005: Message edited by: Yevgeniy Treyvus ]