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

NAME

8       cksum - Calculate a cksum(1) compatible checksum
9

SYNOPSIS

11       package require Tcl  8.2
12
13       package require cksum  ?1.1.2?
14
15       ::crc::cksum  ?-format  format?  ?-chunksize  size?  [  -channel chan |
16       -filename file | string ]
17
18       ::crc::CksumInit
19
20       ::crc::CksumUpdate token data
21
22       ::crc::CksumFinal token
23
24_________________________________________________________________
25

DESCRIPTION

27       This package provides a Tcl implementation of  the  cksum(1)  algorithm
28       based  upon  information  provided at in the GNU implementation of this
29       program as part of the GNU Textutils 2.0 package.
30

COMMANDS

32       ::crc::cksum ?-format format?  ?-chunksize  size?  [  -channel  chan  |
33       -filename file | string ]
34              The  command  takes  string  data  or a channel or file name and
35              returns a checksum value calculated  using  the  cksum(1)  algo‐
36              rithm.  The  result  is  formatted using the format(n) specifier
37              provided or as an unsigned integer (%u) by default.
38

OPTIONS

40       -channel name
41              Return a checksum for the data read from a channel. The  command
42              will  read  data  from the channel until the eof is true. If you
43              need to be able to process events during  this  calculation  see
44              the PROGRAMMING INTERFACE section
45
46       -filename name
47              This is a convenience option that opens the specified file, sets
48              the encoding to binary and then acts as if the  -channel  option
49              had been used. The file is closed on completion.
50
51       -format string
52              Return the checksum using an alternative format template.
53

PROGRAMMING INTERFACE

55       The  cksum  package implements the checksum using a context variable to
56       which additional data can be added at any time. This is expecially use‐
57       ful  in  an  event  based environment such as a Tk application or a web
58       server package. Data to be checksummed  may  be  handled  incrementally
59       during  a  fileevent  handler  in discrete chunks. This can improve the
60       interactive nature of a GUI application and can help to avoid excessive
61       memory consumption.
62
63       ::crc::CksumInit
64              Begins a new cksum context. Returns a token ID that must be used
65              for the remaining functions. An optional seed may  be  specified
66              if required.
67
68       ::crc::CksumUpdate token data
69              Add  data  to the checksum identified by token. Calling CksumUp‐
70              date $token "abcd" is equivalent to calling  CksumUpdate  $token
71              "ab" followed by CksumUpdate $token "cb". See EXAMPLES.
72
73       ::crc::CksumFinal token
74              Returns  the  checksum  value and releases any resources held by
75              this token. Once  this  command  completes  the  token  will  be
76              invalid. The result is a 32 bit integer value.
77

EXAMPLES

79       % crc::cksum "Hello, World!"
80       2609532967
81
82
83       % crc::cksum -format 0x%X "Hello, World!"
84       0x9B8A5027
85
86
87       % crc::cksum -file cksum.tcl
88       1828321145
89
90
91       % set tok [crc::CksumInit]
92       % crc::CksumUpdate $tok "Hello, "
93       % crc::CksumUpdate $tok "World!"
94       % crc::CksumFinal $tok
95       2609532967
96
97

AUTHORS

99       Pat Thoyts
100

BUGS, IDEAS, FEEDBACK

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

SEE ALSO

109       crc32(n), sum(n)
110

KEYWORDS

112       checksum,  cksum,  crc, crc32, cyclic redundancy check, data integrity,
113       security
114
116       Copyright (c) 2002, Pat Thoyts
117
118
119
120
121crc                                  1.1.2                            cksum(n)
Impressum