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

NAME

8       sum - Calculate a sum(1) compatible checksum
9

SYNOPSIS

11       package require Tcl  8.2
12
13       package require sum  ?1.1.2?
14
15       ::crc::sum  ?-bsd  | -sysv? ?-format fmt? ?-chunksize size? [ -filename
16       file | -channel chan | string ]
17
18______________________________________________________________________________
19

DESCRIPTION

21       This package provides a Tcl-only implementation of the  sum(1)  command
22       which  calculates a 16 bit checksum value from the input data.  The BSD
23       sum algorithm is used by default but the SysV algorithm is also  avail‐
24       able.
25

COMMANDS

27       ::crc::sum  ?-bsd  | -sysv? ?-format fmt? ?-chunksize size? [ -filename
28       file | -channel chan | string ]
29              The command takes string data or a file name or  a  channel  and
30              returns  a checksum value calculated using the sum(1) algorithm.
31              The result is formatted using the format(n)  specifier  provided
32              or as an unsigned integer (%u) by default.
33

OPTIONS

35       -sysv  The  SysV  algorithm is fairly naive. The byte values are summed
36              and any overflow is discarded. The lowest 16 bits  are  returned
37              as  the checksum.  Input with the same content but different or‐
38              dering will give the same result.
39
40       -bsd   This algorithm is similar to the SysV version but includes a bit
41              rotation  step  which  provides a dependency on the order of the
42              data values.
43
44       -filename name
45              Return a checksum for the file contents instead of for parameter
46              data.
47
48       -channel chan
49              Return a checksum for the contents of the specified channel. The
50              channel must be open for reading and should  be  configured  for
51              binary translation. The channel will no be closed on completion.
52
53       -chunksize size
54              Set  the  block size used when reading data from either files or
55              channels. This value defaults to 4096.
56
57       -format string
58              Return the checksum using an alternative format template.
59

EXAMPLES

61              % crc::sum "Hello, World!"
62              37287
63
64
65              % crc::sum -format 0x%X "Hello, World!"
66              0x91A7
67
68
69              % crc::sum -file sum.tcl
70              13392
71
72

AUTHORS

74       Pat Thoyts
75

BUGS, IDEAS, FEEDBACK

77       This document, and the package it describes, will  undoubtedly  contain
78       bugs and other problems.  Please report such in the category crc of the
79       Tcllib Trackers  [http://core.tcl.tk/tcllib/reportlist].   Please  also
80       report  any  ideas  for  enhancements  you  may have for either package
81       and/or documentation.
82
83       When proposing code changes, please provide unified diffs, i.e the out‐
84       put of diff -u.
85
86       Note  further  that  attachments  are  strongly  preferred over inlined
87       patches. Attachments can be made by going  to  the  Edit  form  of  the
88       ticket  immediately  after  its  creation, and then using the left-most
89       button in the secondary navigation bar.
90

SEE ALSO

92       cksum(n), crc32(n), sum(1)
93

KEYWORDS

95       checksum, cksum, crc, crc32, cyclic redundancy check,  data  integrity,
96       security, sum
97

CATEGORY

99       Hashes, checksums, and encryption
100
102       Copyright (c) 2002, Pat Thoyts <patthoyts@users.sourceforge.net>
103
104
105
106
107tcllib                               1.1.2                              sum(n)
Impressum