code: public static String digest(String algorithm, byte[] data) throws NoSuchAlgorithmException
     {
  
        MessageDigest md = MessageDigest.getInstance(algorithm);
        byte[] digest = md.digest(data);
        StringBuilder res = new StringBuilder(digest.length * 2);
        for (int i = 0; i < digest.length; i++)
        {
           byte b = digest[i];
           res.append(hexTable[(b >> 4) & 15]);
           res.append(hexTable[b & 15]);
        }
        return res.toString();
     }
docs: Digest the plain string using the given algorithm.
  
  @param algorithm
  The alogrithm for the digest. This algorithm must be supported by the MessageDigest
  class.
  @param data
  the data to digest with the given algorithm
  @return The digested plain text String represented as Hex digits.
  @throws java.security.NoSuchAlgorithmException
  if the desired algorithm is not supported by the MessageDigest class.