date and time created 91/04/04 12:24:44 by bostic
[unix-history] / usr / src / usr.bin / cksum / cksum.1
CommitLineData
bd2a8a16
KB
1.\" Copyright (c) 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\" @(#)cksum.1 5.1 (Berkeley) %G%
7.\"
8.TH CKSUM 1 ""
9.UC 7
10.SH NAME
11cksum \- display file checksums and block counts
12.SH SYNOPSIS
13.ft B
14.nf
15cksum [file ...]
16.fi
17.ft R
18.SH DESCRIPTION
19The
20.I cksum
21utility calculates and writes to standard output a total number of bytes,
22a checksum CRC and the file name for each input file (or the standard input
23by default).
24.PP
25The CRC used is based on the polynomial used for CRC error checking in
26the networking standard ISO 8802-3: 1989.
27The CRC checksum encoding is defined by the generating polynomial:
28.sp
29.RS
30G(x) =
31.RS
32x^32 + x^26 + x^23 + x^22 + x^16 + x^12 +
33x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1
34.RE
35.RE
36.PP
37Mathematically, the CRC value corresponding to a given file is defined by
38the following procedure:
39.RS
40.PP
41The
42.I n
43bits of the file are considered to be the coefficients of a mod 2
44polynomial M(x) of degree
45.IR n -1.
46.PP
47M(x) is multiplied by x^32 (i.e., shifted left 32 bits) and divided by
48G(x) using mod 2 division, producing a remainder R(x) of degree <= 31.
49During the division, each time the intermediate remainder is zero, it
50is changed to the next value from a predefined sequence of 32-bit
51integers before completing the division.
52This sequence is long and complex -- see the source code for more
53information.
54.PP
55The coefficients of R(x) are considered to be a 32-bit sequence.
56.RE
57.PP
58The calculation used is identical to that given in pseudo-code in
59the ACM article listed below.
60.PP
61The
62.I cksum
63utility exits 0 on success, and >0 if an error occurs.
64.SH SEE ALSO
65.IR "Computation of Cyclic Redundancy Checks Via Table Lookup" ,
66Dilip V. Sarwate, Communications of the ACM, August 1988.
67.SH STANDARDS
68.I Cksum
69is expected to conform to IEEE Std 1003.2 (``POSIX'').
70.SH HISTORY
71.I Cksum
72first appeared in 4.4BSD.