crc32

Name

crc32 -- compute CRC-32 Checksum

Synopsis

#include <zlib.h>

uLong crc32(uLong crc, const Bytef * buf, uInt len);

Description

The crc32() function shall compute a running Cyclic Redundancy Check checksum, as defined in ITU-T V.42. On entry, crc 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 crc32() function shall return the new checksum.

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

Return Value

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

Errors

None defined.

Application Usage (informative)

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

     uLong crc = crc32(0L, Z_NULL, 0);

     while (read_buffer(buffer, length) != EOF) {
       crc = crc32(crc, buffer, length);
     }
     if (crc != original_crc) error();