32-bit checksums

CRC32

class numcodecs.checksum32.CRC32[source]
codec_id = 'crc32'

Codec identifier.

encode(buf)

Encode data in buf.

Parameters:
bufbuffer-like

Data to be encoded. May be any object supporting the new-style buffer protocol.

Returns:
encbuffer-like

Encoded data. May be any object supporting the new-style buffer protocol.

decode(buf, out=None)

Decode data in buf.

Parameters:
bufbuffer-like

Encoded data. May be any object supporting the new-style buffer protocol.

outbuffer-like, optional

Writeable buffer to store decoded data. N.B. if provided, this buffer must be exactly the right size to store the decoded data.

Returns:
decbuffer-like

Decoded data. May be any object supporting the new-style buffer protocol.

get_config()

Return a dictionary holding configuration parameters for this codec. Must include an ‘id’ field with the codec identifier. All values must be compatible with JSON encoding.

classmethod from_config(config)

Instantiate codec from a configuration object.

Adler32

class numcodecs.checksum32.Adler32[source]
codec_id = 'adler32'

Codec identifier.

encode(buf)

Encode data in buf.

Parameters:
bufbuffer-like

Data to be encoded. May be any object supporting the new-style buffer protocol.

Returns:
encbuffer-like

Encoded data. May be any object supporting the new-style buffer protocol.

decode(buf, out=None)

Decode data in buf.

Parameters:
bufbuffer-like

Encoded data. May be any object supporting the new-style buffer protocol.

outbuffer-like, optional

Writeable buffer to store decoded data. N.B. if provided, this buffer must be exactly the right size to store the decoded data.

Returns:
decbuffer-like

Decoded data. May be any object supporting the new-style buffer protocol.

get_config()

Return a dictionary holding configuration parameters for this codec. Must include an ‘id’ field with the codec identifier. All values must be compatible with JSON encoding.

classmethod from_config(config)

Instantiate codec from a configuration object.

Fletcher32

class numcodecs.fletcher32.Fletcher32

The fletcher checksum with 16-bit words and 32-bit output

This is the netCDF4/HED5 implementation, which is not equivalent to the one in wikipedia https://github.com/Unidata/netcdf-c/blob/main/plugins/H5checksum.c#L95

With this codec, the checksum is concatenated on the end of the data bytes when encoded. At decode time, the checksum is performed on the data portion and compared with the four-byte checksum, raising RuntimeError if inconsistent.

codec_id = 'fletcher32'

Codec identifier.

encode(buf)

Return buffer plus 4-byte fletcher checksum

decode(buf, out=None)

Check fletcher checksum, and return buffer without it

JenkinsLookup3

class numcodecs.checksum32.JenkinsLookup3(initval: int = 0, prefix=None)[source]

Bob Jenkin’s lookup3 checksum with 32-bit output

This is the HDF5 implementation. https://github.com/HDFGroup/hdf5/blob/577c192518598c7e2945683655feffcdbdf5a91b/src/H5checksum.c#L378-L472

With this codec, the checksum is concatenated on the end of the data bytes when encoded. At decode time, the checksum is performed on the data portion and compared with the four-byte checksum, raising RuntimeError if inconsistent.

Attributes:

initval: initial seed passed to the hash algorithm, default: 0 prefix: bytes prepended to the buffer before evaluating the hash, default: None

codec_id = 'jenkins_lookup3'

Codec identifier.

initval
prefix
encode(buf)[source]

Return buffer plus 4-byte Bob Jenkin’s lookup3 checksum

decode(buf, out=None)[source]

Check Bob Jenkin’s lookup3 checksum, and return buffer without it