chiark / gitweb /
Add lots of references to manual pages, and fix a typo.
[mLib] / man / crc32.3
b6b9d458 1.\" -*-nroff-*-
08da152e 2.TH crc32 3 "8 May 1999" "mLib"
b6b9d458 3.SH NAME
4crc32 \- calculate 32-bit CRC
08da152e 5.\" @crc32
b6b9d458 6.SH SYNOPSIS
8.B "#include <mLib/crc32.h>"
10.BI "int crc32(unsigned long " crc ", const void *" buf ", size_t " sz );
11.BI CRC32( result ", " crc ", " buf ", " sz )
15.B crc32
16function calculates a 32-bit cyclic redundancy check of the data block
17at address
18.I buf
19and size
20.I sz
21passed to it.
23The function is restartable. For a first call, pass zero as the value
24of the
25.I crc
26argument; for subsequent blocks, pass in the previous output. The final
27answer is equal to the result you'd get from computing a CRC over the
28concatenation of the individual blocks.
31.B CRC32
32macro calculates a CRC inline. The calculated CRC value is placed in
33the variable named by
34.IR result .
35Only use the macro version when efficiency is a major concern: it makes
36the code rather harder to read.
38Note that a CRC is not cryptographically strong: it's fairly easy for an
39adversary to construct blocks of data with any desired CRC, or to modify
40a given block in a way which doesn't change its (unknown) CRC.
42The exact behaviour of the CRC is beyond the scope of this manual;
43suffice to say that the result is, in some suitable representation, the
44remainder after division in the finite field GF(2^32) of the block by a
45carefully chosen polynomial of order 32.
47The return value is the 32-bit CRC of the input block.
08da152e 48.SH "SEE ALSO"
49.BR mLib (3).
b6b9d458 50.SH AUTHOR
51Mark Wooding, <>