Give a simple hash chain example in Java I am looking for a very simple example of cryptography hash chain source code. Could you forward me some examples or link, guys?
For example, https://en.wikipedia.org/wiki/Hash_chain [1].
h(h(h(h(x)))) gives a hash chain of length 4. h=hash, x=password
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.