/** * Compute the CRC32 of the segment of the byte array given by the specified size and offset * * @param bytes The bytes to checksum * @param offset the offset at which to begin checksumming * @param size the number of bytes to checksum * @return The CRC32 */ public static long crc32(byte[] bytes, int offset, int size) { Crc32 crc = new Crc32(); crc.update(bytes, offset, size); return crc.getValue(); }
/** * Compute the CRC32 of a byte buffer from a given offset (relative to the buffer's current position) * * @param buffer The buffer with the underlying data * @param offset The offset relative to the current position * @param size The number of bytes beginning from the offset to include * @return The CRC32 */ public static long crc32(ByteBuffer buffer, int offset, int size) { Crc32 crc = new Crc32(); Checksums.update(crc, buffer, offset, size); return crc.getValue(); }