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 or generally in your sum(1) manual page.

For example using the BSD algorithm:

  % package require sum
  % crc::sum "Hello, World!"
  % crc::sum -file sum.tcl
  % crc::sum -format 0x%x -file sum.tcl

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!"
  % crc::sum -sysv "World, Hello!"

See the code at

Category Package subset Tcllib See also crc and cksum