code: public static byte[] computeHash(File file, MessageDigest digest,
              long from, long until) throws IOException {
          Preconditions.checkArgument(from >= 0, "negative offset");
          Preconditions.checkArgument(until > from, "end offset is smaller or equal to start offset");
          Preconditions.checkArgument(until <= file.length(), "end offset is greater than file length");
          try (RandomAccessFile raf = new RandomAccessFile(file, "r")) {
              byte[] buffer = new byte[BUFFER_SIZE];
              int readbytes;
              long byteSum = from;
              raf.seek(from);
              while ((readbytes = raf.read(buffer)) != -1 && byteSum <= until) {
                  byteSum += readbytes;
                  if (byteSum > until) {
                      readbytes -= (byteSum - until);
                  }
                  digest.update(buffer, 0, readbytes);
              }
              return digest.digest();
          }
      }
docs: Computes the hash value for the file bytes from offset <code>from</code>
  until offset <code>until</code>, using the hash instance as defined by
  the hash type.
  
  @param file
  the file to compute the hash from
  @param digest
  the message digest instance
  @param from
  file offset to start from
  @param until
  file offset for the end
  @return hash value as byte array
  @throws IOException