Here is an article with some simple Java code that shows how to compute both checksums.I have understood the above example.The only question is why is he converting the hash into hexadecimal value? is it necessary?
The 'normal' use is to provide the digest value as a hex string. If you download files from the web a lot of times they will provide a digest value (MD5 or SHA1) you can use to verify that the downloaded file was not corrupted and is, in fact, the correct file. Those sites provide the digest value as a hex string. That makes it easy to cut & paste to compare with another value.
// get the hash value as byte array byte hash = algorithm.digest();
Having the digest value as a hex string makes it easier to manipulate.
public static String calculateHash(MessageDigest algorithm,