crc16(n) | Cyclic Redundancy Checks | crc16(n) |
crc16 - Perform a 16bit Cyclic Redundancy Check
package require Tcl 8.2
package require crc16 ?1.1.1?
::crc::crc16 ?-format format? ?-seed value? ?-implementation procname? message
::crc::crc16 ?-format format? ?-seed value? ?-implementation procname? -filename file
::crc::crc-ccitt ?-format format? ?-seed value? ?-implementation procname? message
::crc::crc-ccitt ?-format format? ?-seed value? ?-implementation procname? -filename file
::crc::xmodem ?-format format? ?-seed value? ?-implementation procname? message
::crc::xmodem ?-format format? ?-seed value? ?-implementation procname? -filename file
This package provides a Tcl-only implementation of the CRC algorithms based upon information provided at http://www.microconsultants.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.
A number of common polynomials are in use with the CRC algorithm and the most commonly used of these are included in this package. For convenience each of these has a command alias in the crc namespace.
It is possible to implement the CRC-32 checksum using this crc16 package as the implementation is sufficiently generic to extend to 32 bit checksums. As an example this has been done already - however this is not the fastest method to implement this algorithm in Tcl and a separate crc32 package is available.
The package provides some implementations of standard CRC polynomials for the XMODEM, CCITT and the usual CRC-16 checksum. For convenience, additional commands have been provided that make use of these implementations.
% 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
Pat Thoyts
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category crc of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation.
cksum(n), crc32(n), sum(n)
checksum, cksum, crc, crc16, crc32, cyclic redundancy check, data integrity, security
Hashes, checksums, and encryption
Copyright (c) 2002, Pat Thoyts
1.1.1 | crc |