code: public static String calculateMD5(Object val)
      {
          MessageDigest md = null;
          try
          {
              md = MessageDigest.getInstance("MD5");
          }
          catch (NoSuchAlgorithmException e)
          {
              logger.error("Unable to calculate MD5 for file, Caused By: ", e);
          }
          md.update((byte[]) val);
  
          byte[] digest = md.digest();
          return DatatypeConverter.printHexBinary(digest).toLowerCase();
      }
docs: Calculate m d5.
  
  @param val
  the val
  @return the string