cksum(3tcl)
๐ NAME ๐
bestie we're looking at cksum from the Cyclic Redundancy Checks family, also known as cksum(3tcl) โ and it does exactly one iconic thing: it calculates a cksum(1) compatible checksum. that's it. that's the whole assignment. ๐
โจ SYNOPSIS โจ
package require Tcl 8.5 9
package require cksum ?1.1.5?
::crc::cksum ?-format format? ?-chunksize size? [ -channel chan |
-filename file | string ]
::crc::CksumInit
::crc::CksumUpdate token data
::crc::CksumFinal token
๐ฆ DESCRIPTION ๐ฆ
so here's the tea ๐: this package is a pure Tcl implementation of the cksum(1) algorithm, and it's built on information provided in the GNU implementation of that program as part of the GNU Textutils 2.0 package. it's giving "faithful recreation, no notes." periodt.
๐ COMMANDS ๐
::crc::cksum ?-format format? ?-chunksize size? [ -channel chan | -filename file | string ]โ you hand it string data, or a channel, or a file name, and it hands you back a checksum value computed with thecksum(1)algorithm. the result gets formatted using theformat(3tcl)specifier you provide, or โ if you don't provide one โ as an unsigned integer (%u) by default. she has a default. she's low maintenance. ๐
๐ OPTIONS ๐
-channel nameโ returns a checksum for the data read from a channel. the command just keeps reading from the channel untileofis true. > heads up bestie: if you need to be able to process events during this calculation, go look at the PROGRAMMING INTERFACE section instead, iykyk. ๐ซถ-filename nameโ this is the convenience option, the "girl who does your homework for you" option. it opens the specified file, sets the encoding tobinary, and then acts exactly as if you'd used-channel. the file is closed when it's done. no cap. ๐ฅ-format stringโ returns the checksum using an alternative format template. cute, custom, iconic. โจ
๐ PROGRAMMING INTERFACE ๐
okay so this package implements the checksum using a context variable that you can keep adding data to whenever you want. this is especially useful in an event based environment like a Tk application or a web server package โ fr fr, that's the main character use case. data to be checksummed can be handled incrementally during a fileevent handler in discrete chunks. this can improve the interactive nature of a GUI application, and it can help you avoid excessive memory consumption. slay. ๐
::crc::CksumInitโ begins a new cksum context. returns a token ID that you must use for the remaining functions. an optional seed may be specified if required. ๐ฑ::crc::CksumUpdate token dataโ adds data to the checksum identified by token. callingCksumUpdate $token "abcd"is equivalent to callingCksumUpdate $token "ab"followed byCksumUpdate $token "cb". see EXAMPLES for the receipts. ๐::crc::CksumFinal tokenโ returns the checksum value and releases any resources held by this token. > once this command completes, the token will be invalid. gone. expired. ๐ the result is a 32 bit integer value.
๐ธ EXAMPLES ๐ธ
% crc::cksum "Hello, World!"
2609532967
% crc::cksum -format 0x%X "Hello, World!"
0x9B8A5027
% crc::cksum -file cksum.tcl
1828321145
% set tok [crc::CksumInit]
% crc::CksumUpdate $tok "Hello, "
% crc::CksumUpdate $tok "World!"
% crc::CksumFinal $tok
2609532967
look at that last one โ two little updates, one big beautiful result. incremental girlie behavior and we love her for it. ๐
โญ AUTHORS โญ
Pat Thoyts. the icon, the legend, the moment. ๐ซก
๐ง BUGS, IDEAS, FEEDBACK ๐ง
not to be dramatic but this document, and the package it describes, will undoubtedly contain bugs and other problems. it's giving "we're all just doing our best." ๐ญ please report such in the category crc of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist](http://core.tcl.tk/tcllib/reportlist). and please also report any ideas for enhancements you may have for either the package and/or the documentation โ we want them, bestie, we're obsessed with them. ๐
when proposing code changes, please provide unified diffs, i.e the output of diff -u.
note further that attachments are strongly preferred over inlined patches. attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. that's the whole tutorial, you got this. ๐ฏ
๐ฎ SEE ALSO ๐ฎ
๐ซ KEYWORDS ๐ซ
checksum, cksum, crc, crc32, cyclic redundancy check, data integrity, security
๐ CATEGORY ๐
Hashes, checksums, and encryption
๐ COPYRIGHT ๐
Copyright (c) 2002, Pat Thoyts
okay that's the whole page, you're officially certified in cksum behavior ๐โจ this was tcllib version 1.1.5, page cksum(3tcl) โ thank you for coming to my TED talk, go checksum something and stay iconic. ๐
๐
๐ฆ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 ยท Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 ยท Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 ยท Tcl
- Copyright (c) 2002, Pat Thoyts
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms