static void generateChecksums(byte[] indata, int startOffset, int endOffset, byte[] outdata,
    int outOffset, ChecksumType checksumType, int bytesPerChecksum) throws IOException {

    if (checksumType == ChecksumType.NULL) {
      return; // No checksum for this block.
    }

    DataChecksum checksum =
      DataChecksum.newDataChecksum(checksumType.getDataChecksumType(), bytesPerChecksum);

    checksum.calculateChunkedSums(ByteBuffer.wrap(indata, startOffset, endOffset - startOffset),
      ByteBuffer.wrap(outdata, outOffset, outdata.length - outOffset));
  }
Generates a checksum for all the data in indata. The checksum is written to outdata.
@param indata           input data stream
@param startOffset      starting offset in the indata stream from where to compute checkums
                        from
@param endOffset        ending offset in the indata stream upto which checksums needs to be
                        computed
@param outdata          the output buffer where checksum values are written
@param outOffset        the starting offset in the outdata where the checksum values are
                        written
@param checksumType     type of checksum
@param bytesPerChecksum number of bytes per checksum value
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/ChecksumUtil.java