adler32 -- Compute Adler 32 Checksum


#include <zlib.h>

uLong adler32(uLong adler, const Bytef * buf, uInt len);


The adler32() function shall compute a running Adler-32 checksum (as described in RFC 1950: ZLIB Compressed Data Format Specication). On entry, adler is the previous value for the checksum, and buf shall point to an array of len bytes of data to be added to this checksum. The adler32() function shall return the new checksum.

If buf is NULL (or Z_NULL), adler32() shall return the initial checksum.

Return Value

The adler32() function shall return the new checksum value.


None defined.

Application Usage (informative)

The following code fragment demonstrates typical usage of the adler32() function:

     uLong adler = adler32(0L, Z_NULL, 0);

     while (read_buffer(buffer, length) != EOF) {
       adler = adler32(adler, buffer, length);
     if (adler != original_adler) error();