public void updateChecksum(Memory memory, AddressSetView addrSet, TaskMonitor monitor,
			boolean onesComp, boolean twosComp) throws MemoryAccessException, CancelledException {

		byte[] bytes = new byte[1024];
		long crc;
		try (CheckedInputStream cis =
			new CheckedInputStream(new MemoryInputStream(memory, addrSet), new CRC32())) {
			while (cis.read(bytes) > 0) {
				if (monitor.isCancelled()) {
					throw new CancelledException();
				}
			}
			crc = cis.getChecksum().getValue();
		}
		catch (IOException e) {
			throw new MemoryAccessException(e.getMessage());
		}

		if (onesComp) {
			crc = ~crc;
		}
		else if (twosComp) {
			crc = -crc;
		}
		checksum = toArray(crc, 4);
	}
Computes the checksum with the given options.

@param memory The memory to generate the checksum from.
@param addrSet The addresses over which to generate the checksum.
@param monitor Cancelable task monitor to cancel the computation.
@param onesComp True if the checksum should be complemented with a ones complement.
@param twosComp True if the checksum should be complemented with a twos complement.
@throws MemoryAccessException If there was a problem reading the memory.
@throws CancelledException If the user cancels the task.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/checksums/CRC32ChecksumAlgorithm.java