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

NAME

8       crc16 - Perform a 16bit Cyclic Redundancy Check
9

SYNOPSIS

11       package require Tcl  8.2
12
13       package require crc16  ?1.1.1?
14
15       ::crc::crc16  ?-format format? ?-seed value? ?-implementation procname?
16       message
17
18       ::crc::crc16 ?-format format? ?-seed value? ?-implementation  procname?
19       -filename file
20
21       ::crc::crc-ccitt  ?-format format? ?-seed value? ?-implementation proc‐
22       name? message
23
24       ::crc::crc-ccitt ?-format format? ?-seed value? ?-implementation  proc‐
25       name? -filename file
26
27       ::crc::xmodem ?-format format? ?-seed value? ?-implementation procname?
28       message
29
30       ::crc::xmodem ?-format format? ?-seed value? ?-implementation procname?
31       -filename file
32
33_________________________________________________________________
34

DESCRIPTION

36       This  package  provides a Tcl-only implementation of the CRC algorithms
37       based   upon   information    provided    at    http://www.microconsul
38       tants.com/tips/crc/crc.txt There are a number of permutations available
39       for calculating CRC checksums and this package can handle all of  them.
40       Defaults are set up for the most common cases.
41

COMMANDS

43       ::crc::crc16  ?-format format? ?-seed value? ?-implementation procname?
44       message
45
46       ::crc::crc16 ?-format format? ?-seed value? ?-implementation  procname?
47       -filename file
48
49       ::crc::crc-ccitt  ?-format format? ?-seed value? ?-implementation proc‐
50       name? message
51
52       ::crc::crc-ccitt ?-format format? ?-seed value? ?-implementation  proc‐
53       name? -filename file
54
55       ::crc::xmodem ?-format format? ?-seed value? ?-implementation procname?
56       message
57
58       ::crc::xmodem ?-format format? ?-seed value? ?-implementation procname?
59       -filename file
60              The  command takes either string data or a file name and returns
61              a checksum value calculated using the CRC algorithm. The command
62              used  sets up the CRC polynomial, initial value and bit ordering
63              for the desired standard checksum  calculation.  The  result  is
64              formatted  using  the  format(n)  specifier  provided  or  as an
65              unsigned integer (%u) by default.
66
67              A number of common polynomials are in use with the CRC algorithm
68              and  the  most commonly used of these are included in this pack‐
69              age. For convenience each of these has a command  alias  in  the
70              crc namespace.
71
72              It is possible to implement the CRC-32 checksum using this crc16
73              package as the implementation is sufficiently generic to  extend
74              to  32 bit checksums. As an example this has been done already -
75              however this is not the fastest method to implement  this  algo‐
76              rithm in Tcl and a separate crc32 package is available.
77

OPTIONS

79       -filename name
80              Return a checksum for the file contents instead of for parameter
81              data.
82
83       -format string
84              Return the checksum using an alternative format template.
85
86       -seed value
87              Select an alternative seed value for the  CRC  calculation.  The
88              default  is 0 for the CRC16 calculation and 0xFFFF for the CCITT
89              version.  This can be useful for calculating the  CRC  for  data
90              structures  without  first converting the whole structure into a
91              string. The CRC of the previous member can be used as  the  seed
92              for  calculating the CRC of the next member. It is also used for
93              accumulating a checksum from fragments of a  large  message  (or
94              file)
95
96       -implementation procname
97              This hook is provided to allow users to provide their own imple‐
98              mentation (perhaps a C compiled extension). The procedure  spec‐
99              fied  is called with two parameters. The first is the data to be
100              checksummed and the second is the  seed  value.  An  integer  is
101              expected as the result.
102
103              The  package provides some implementations of standard CRC poly‐
104              nomials for the XMODEM, CCITT and the usual CRC-16 checksum. For
105              convenience,  additional  commands  have been provided that make
106              use of these implementations.
107

EXAMPLES

109       % crc::crc16 "Hello, World!"
110       64077
111
112
113       % crc::crc-ccitt "Hello, World!"
114       26586
115
116
117       % crc::crc16 -format 0x%X "Hello, World!"
118       0xFA4D
119
120
121       % crc::crc16 -file crc16.tcl
122       51675
123
124

AUTHORS

126       Pat Thoyts
127

BUGS, IDEAS, FEEDBACK

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

SEE ALSO

136       cksum(n), crc32(n), sum(n)
137

KEYWORDS

139       checksum, cksum, crc,  crc16,  crc32,  cyclic  redundancy  check,  data
140       integrity, security
141
143       Copyright (c) 2002, Pat Thoyts
144
145
146
147
148crc                                  1.1.1                            crc16(n)
Impressum