NAME
crc16 - Perform a 16bit Cyclic Redundancy Check
SYNOPSIS
package require TTccll 88..22 package require ccrrcc1166 ??11..11??::::ccrrcc::::ccrrcc1166 ?-format format? ?-seed value? ?-implementation procname?
message::::ccrrcc::::ccrrcc1166 ?-format format? ?-seed value? ?-implementation procname?
-filename file
::::ccrrcc::::ccrrcc-cccciitttt ?-format format? ?-seed value? ?-implementation proc-
name? message::::ccrrcc::::ccrrcc-cccciitttt ?-format format? ?-seed value? ?-implementation proc-
name? -filename file
DESCRIPTION
This package provides a Tcl-only implementation of the CRC algorithms
based upon information provided at http://www.microconsul-
tants.com/tips/crc/crc.txt There are a number of permutations available for calculating CRC checksums and this package can handle all of them. Defaults are set up for the most common cases. CCOOMMMMAANNDDSS::::ccrrcc::::ccrrcc1166 ?-format format? ?-seed value? ?-implementation procname?
message::::ccrrcc::::ccrrcc1166 ?-format format? ?-seed value? ?-implementation procname?
-filename file
::::ccrrcc::::ccrrcc-cccciitttt ?-format format? ?-seed value? ?-implementation proc-
name? message::::ccrrcc::::ccrrcc-cccciitttt ?-format format? ?-seed value? ?-implementation proc-
name? -filename file
The command takes string data or a file name and returns a checksum value calculated using the CRC algorithm. The command used sets up the CRC polynomial, initial value and bit ordering for the desired standard checksum calculation. The result is formatted using the format(n) specifier provided or as anunsigned integer (%u) by default.
OOPPTTIIOONNSS-filename name
Return a checksum for the file contents instead of for parameter data.-format string
Return the checksum using an alternative format template.-seed value
Select an alternative seed value for the CRC calculation. The default is 0 for the CRC16 calculation and 0xFFFF for the CCITT version. This can be useful for calculating the CRC for data structures without first converting the whole structure into a string. The CRC of the previous member can be used as the seed for calculating the CRC of the next member. It is also used for accumulating a checksum from fragments of a large message (or file)-implementation procname
This hook is provided to allow users to provide their own imple-
mentation (perhaps a C compiled extension). The procedure spec-
fied is called with two parameters. The first is the data to be checksummed and the second is the seed value. An integer is expected as the result. EEXXAAMMPPLLEESS% crc::crc16 "Hello, World!"
64077% crc::crc-ccitt "Hello, World!"
26586% crc::crc16 -format 0x%X "Hello, World!"
0xFA4D% crc::crc16 -file crc16.tcl
51675 AUTHORS Pat ThoytsSEE ALSO
cksum(n), crc32(n), sum(n) KKEEYYWWOORRDDSSchecksum, cksum, crc, crc16, crc32, cyclic redundancy check, data
integrity, security COPYRIGHT Copyright (c) 2002, Pat Thoytscrc 1.1 crc16(n)