Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

compress.checksum

import compress

compress exposes this as compress.checksum, so import compress is enough and the names are called as compress.checksum.*. import compress.checksum reaches the same definitions directly.

This is the checksum submodule for the compress module.

Functions

adler32()

compress.checksum.adler32(data, initial) -> number

Updates a running Adler-32 checksum with the bytes buf[0,len-1] and return the updated checksum.

Parameters

  • data (bytes|string)
  • initial (?number) — Default 1: the algorithm’s own defined identity/seed value (RFC 1950). Pass the previously returned checksum here to continue an incremental computation across multiple calls.

Returns number

Note: An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed much faster.

crc32()

compress.checksum.crc32(data, initial) -> number

Update a running CRC-32 checksum with the bytes buf[0,len-1] and return the updated CRC-32 checksum.

Parameters

  • data (bytes|string)
  • initial (?number) — Default 0: the algorithm’s own defined identity/seed value. Pass the previously returned checksum here to continue an incremental computation across multiple calls.

Returns number


2021, Richard Ore and Zuri contributors