OBSCURING A PASSWORD If you want to send a password from a browser to a server and you don't really care about it being cryptographically secure but you would prefer that it wasn't in plain text, then use a Message Digest algorithm. Message Digest algorithms are functions that can only be computed one way. Once the algorithm has been applied to a value, it is not possible to go backwards and find out the original value. The only way is to pass in random input until you get the value. Message Digest algorithms are more commonly known as "one-way hash functions," but due to the similarity with hashing for Hashtables, we will ignore that name. A very simplified example is the square-function. If you square the number 5, there is only one possible result. However, if you start with the answer 25, it is not possible to tell whether the original number was 5 or -5. A Message Digest algorithm is merely a very complex version of this. Java provides an easy way to accomplish this via the java.security.MessageDigest class. As with all parts of Java security, it is possible to plug in extra algorithms, but the default JVMs come with two Message Digests as standard: MD5 and SHA-1. The MessageDigest class turns a series of bytes into another series of bytes, so you also need to handle turning a String into bytes and vice versa. Here's the code: import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; .... String password = "josephine"; MessageDigest md = null; try { // MD5 is the normal one to use, else put SHA-1 here. md = MessageDigest.getInstance("MD5"); } catch(NoSuchAlgorithmException nsae) { nsae.printStackTrace(); } byte[] input = password.getBytes(); md.update(input); byte[] output = md.digest(); md.reset(); return convertToHexString(output); Note that the major thing missing is the convertToHexString method. The reason for converting the bytes back to a String is that it's easier to debug. And putting a String into a file or database is a lot simpler than adding the binary byte array. Here's an implementation of this method: static public String convertToHexString(byte[] bytes) { int size = bytes.length; StringBuffer buffer = new StringBuffer(size*2); for(int i=0; i