all Python 3zlibfunction
zlib.adler32()
checksums
Computes the Adler-32 checksum — faster than CRC-32 but weaker; it can be computed in pieces.
Syntax
zlib.adler32(data[, value])
The zlib format itself uses it at the end of a stream, but crc32 is the usual choice for your own data: Adler-32 is weak at catching errors in messages only a few bytes long. Its starting value is 1, not 0 — adler32(b'') == 1 — so when computing in pieces, omit the second argument on the first call instead of passing 0. It is not a cryptographic hash.
Examples
import zlib
print(zlib.adler32(b''), zlib.crc32(b'')) # → 1 0
running = zlib.adler32(b'hel')
print(zlib.adler32(b'lo', running) == zlib.adler32(b'hello')) # → True
print(zlib.adler32(b'lo', 0) == zlib.adler32(b'lo')) # → False — начало не с 0
See also
Open in the full glossarydocs.python.orgReport an inaccuracy