Give a simple hash chain example in Java
I'm not a Java programmer, and I didn't compile this, but I modified answer to this question to achieve a hash chain of length equal to four.

byte[] bytesOfMessage = yourString.getBytes("UTF-8");

MessageDigest md = MessageDigest.getInstance("MD5");

byte[] thedigest = md.digest(md.digest(md.digest(md.digest(bytesOfMessage))));


PS. Don't use MD5 for crypto. It's not secure.