A Tcl implementation of the unix sum(1) command is now part of Tcllib and should appear in the 1.2 release. Both the BSD and SysV algorithms are implemented although more consistent results across many platforms may be obtained using the cksum command.
The sum algorithms return a 16 bit checksum of the input data calculated by summing the values of each byte of data. The BSD algorithm includes a right bit-rotation which ensures that the order of the bytes is also significant.
Information about the sum(1) command can be found at http://www.tac.eu.org/cgi-bin/man-cgi?sum+1 or generally in your sum(1) manual page.
For example using the BSD algorithm:
% package require sum 1.0 % crc::sum "Hello, World!" 37287 % crc::sum -file sum.tcl 16358 % crc::sum -format 0x%x -file sum.tcl 0x3fe6
The SysV algorithm is less robust - meaning that different data may give the same checksum. cksum is more robust still and md5sum is yet more so.
% crc::sum -sysv "Hello, World!" 1129 % crc::sum -sysv "World, Hello!" 1129
See the code at http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tcllib/tcllib/modules/crc/sum.tcl?rev=HEAD&content-type=text/vnd.viewcvs-markup
Category Package subset Tcllib See also crc and cksum