code: public String generateChecksum(InputStream inStream) {
          try {
              byte[] buf = new byte[4096];
              int numRead = 0;
              long totalBytesRead = 0;
              while ((numRead = readFromStream(inStream, buf)) != -1) {
                  digest.update(buf, 0, numRead);
                  totalBytesRead += numRead;
  
                  if (log.isDebugEnabled()) {
                      if (totalBytesRead % (1000 * 1000 * 1000) == 0) {
                          log.debug("Total bytes read: {}", totalBytesRead);
                      }
                  }
              }
              return checksumBytesToString(digest.digest());
          } finally {
              digest.reset();
          }
      }
docs: This method generates checksum of content in arg stream.
  Warning: this method is NOT threadsafe.
  
  @param inStream Content used as target of checksum.
  @return string representation of the generated checksum.