1crc32(n)                   Cyclic Redundancy Checks                   crc32(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       crc32 - Perform a 32bit Cyclic Redundancy Check
9

SYNOPSIS

11       package require Tcl  8.2
12
13       package require crc32  ?1.3?
14
15       ::crc::crc32 ?-format format? ?-seed value? [ -channel chan | -filename
16       file | message ]
17
18       ::crc::Crc32Init ?seed?
19
20       ::crc::Crc32Update token data
21
22       ::crc::Crc32Final token
23
24_________________________________________________________________
25

DESCRIPTION

27       This package provides a Tcl  implementation  of  the  CRC-32  algorithm
28       based   upon   information   provided   at  http://www.naaccr.org/stan
29       dard/crc32/document.html If either the critcl package or the Trf  pack‐
30       age  are  available  then  a compiled version may be used internally to
31       accelerate the checksum calculation.
32

COMMANDS

34       ::crc::crc32 ?-format format? ?-seed value? [ -channel chan | -filename
35       file | message ]
36              The  command  takes either string data or a channel or file name
37              and returns a checksum value calculated using the  CRC-32  algo‐
38              rithm.  The  result  is  formatted using the format(n) specifier
39              provided. The default is to return  the  value  as  an  unsigned
40              integer (format %u).
41

OPTIONS

43       -channel name
44              Return  a checksum for the data read from a channel. The command
45              will read data from the channel until the eof is  true.  If  you
46              need  to  be  able to process events during this calculation see
47              the PROGRAMMING INTERFACE section
48
49       -filename name
50              This is a convenience option that opens the specified file, sets
51              the  encoding  to binary and then acts as if the -channel option
52              had been used. The file is closed on completion.
53
54       -format string
55              Return the checksum using an alternative format template.
56
57       -seed value
58              Select an alternative seed value for the  CRC  calculation.  The
59              default  is  0xffffffff.  This can be useful for calculating the
60              CRC for data  structures  without  first  converting  the  whole
61              structure  into  a string. The CRC of the previous member can be
62              used as the seed for calculating the CRC of the next member.
63

PROGRAMMING INTERFACE

65       The CRC-32 package implements the checksum using a context variable  to
66       which additional data can be added at any time. This is expecially use‐
67       ful in an event based environment such as a Tk  application  or  a  web
68       server  package.  Data  to  be checksummed may be handled incrementally
69       during a fileevent handler in discrete chunks.  This  can  improve  the
70       interactive nature of a GUI application and can help to avoid excessive
71       memory consumption.
72
73       ::crc::Crc32Init ?seed?
74              Begins a new CRC32 context. Returns a token ID that must be used
75              for  the  remaining functions. An optional seed may be specified
76              if required.
77
78       ::crc::Crc32Update token data
79              Add  data  to  the  checksum  identified   by   token.   Calling
80              Crc32Update  $token  "abcd" is equivalent to calling Crc32Update
81              $token "ab" followed by Crc32Update $token "cb". See EXAMPLES.
82
83       ::crc::Crc32Final token
84              Returns the checksum value and releases any  resources  held  by
85              this  token.  Once  this  command  completes  the  token will be
86              invalid. The result is a 32 bit integer value.
87

EXAMPLES

89       % crc::crc32 "Hello, World!"
90       3964322768
91
92
93       % crc::crc32 -format 0x%X "Hello, World!"
94       0xEC4AC3D0
95
96
97       % crc::crc32 -file crc32.tcl
98       483919716
99
100
101       % set tok [crc::Crc32Init]
102       % crc::Crc32Update $tok "Hello, "
103       % crc::Crc32Update $tok "World!"
104       % crc::Crc32Final $tok
105       3964322768
106
107

AUTHORS

109       Pat Thoyts
110

BUGS, IDEAS, FEEDBACK

112       This document, and the package it describes, will  undoubtedly  contain
113       bugs and other problems.  Please report such in the category crc of the
114       Tcllib  SF  Trackers  [http://sourceforge.net/tracker/?group_id=12883].
115       Please  also  report any ideas for enhancements you may have for either
116       package and/or documentation.
117

SEE ALSO

119       cksum(n), crc16(n), sum(n)
120

KEYWORDS

122       checksum, cksum, crc, crc32, cyclic redundancy check,  data  integrity,
123       security
124
126       Copyright (c) 2002, Pat Thoyts
127
128
129
130
131crc                                   1.3                             crc32(n)
Impressum