cksum(3tcl)

๐Ÿ“ฆ
version 2.0 ยท 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

๐Ÿ‘‘ 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 the cksum(1) algorithm. the result gets formatted using the format(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 until eof is 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 to binary, 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. calling CksumUpdate $token "abcd" is equivalent to calling CksumUpdate $token "ab" followed by CksumUpdate $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 ๐Ÿ”ฎ

crc32(3tcl), sum(3tcl)


๐Ÿ’ซ KEYWORDS ๐Ÿ’ซ

checksum, cksum, crc, crc32, cyclic redundancy check, data integrity, security


๐Ÿ“ CATEGORY ๐Ÿ“

Hashes, checksums, and encryption


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