sum(n)

๐Ÿ“ฆ
version 2.0 ยท 2 versions
, in fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

๐Ÿ’– sum(n) โ€” Cyclic Redundancy Checks ๐Ÿ’–

okay bestie, buckle up, we're doing the sum page and it's actually so cute once you get it. this is sum(n), the Tcl manual page, and by the end you're gonna be checksumming like it's nothing. periodt. โœจ


๐ŸŒธ NAME ๐ŸŒธ

sum โ€” Calculate a sum(1) compatible checksum ๐Ÿ’…


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

package require Tcl 8.5 9

package require sum ?1.1.3?

::crc::sum  ?-bsd  |  -sysv? ?-format fmt? ?-chunksize size? [ -filename
file | -channel chan | string ]

โœจ DESCRIPTION โœจ

so this package is a Tcl-only implementation of the sum(1) command โ€” no cap, pure Tcl, no sneaky C hiding in there. it calculates a 16 bit checksum value from whatever input data you hand it. ๐Ÿงฎ

by default it uses the BSD sum algorithm, but the SysV algorithm is also available if that's your vibe. both are in the building, you just gotta pick. ๐Ÿซถ


๐Ÿ‘‘ COMMANDS ๐Ÿ‘‘

  • ::crc::sum ?-bsd | -sysv? ?-format fmt? ?-chunksize size? [ -filename file | -channel chan | string ] โ€” okay so this command takes string data, or a file name, or a channel, and it hands you back a checksum value calculated with the sum(1) algorithm. the result gets formatted using the format(n) specifier you provide โ€” or, if you don't provide one, it's just an unsigned integer (%u) by default. the way it just... formats for you? iconic. ๐Ÿ’…

๐Ÿ’– OPTIONS ๐Ÿ’–

  • -sysv โ€” the SysV algorithm is, ngl, fairly naive. it just sums up all the byte values and tosses any overflow in the bin. the lowest 16 bits come back as your checksum. heads up though: input with the same content but a different ordering gives you the same result. so if order matters to you... it does not matter to SysV. ๐Ÿ’€
  • -bsd โ€” this one is similar to the SysV version but it adds a bit rotation step, which means it actually has a dependency on the order of the data values. so yes, order matters here. main character behavior tbh. ๐ŸŒˆ
  • -filename name โ€” gives you a checksum for the file contents instead of for the parameter data. ๐Ÿ“
  • -channel chan โ€” gives you a checksum for the contents of the channel you specify. the channel must be open for reading and should be configured for binary translation. and fyi: the channel will not be closed on completion, so don't expect it to dip on you. ๐Ÿ™ˆ
  • -chunksize size โ€” sets the block size used when reading data from either files or channels. this value defaults to 4096. ๐Ÿ“ฆ
  • -format string โ€” returns the checksum using an alternative format template. glow-up for your output. โœจ

๐Ÿฆ‹ EXAMPLES ๐Ÿฆ‹

% crc::sum "Hello, World!"
37287

% crc::sum -format 0x%X "Hello, World!"
0x91A7

% crc::sum -file sum.tcl
13392

like?? look at that. 37287, 0x91A7, 13392. she ate. ๐Ÿ”ฅ


๐ŸŒธ AUTHORS ๐ŸŒธ

Pat Thoyts โ€” the legend themselves. ๐Ÿ‘‘


๐Ÿ˜ญ BUGS, IDEAS, FEEDBACK ๐Ÿ˜ญ

okay so real talk: this document, and the package it describes, will undoubtedly contain bugs and other problems. it's giving honest. please report such in the category crc of the Tcllib Trackers:

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 wanna hear it, fr fr. ๐Ÿซถ

when proposing code changes, please provide unified diffs, i.e. the output of diff -u. ๐Ÿ’…

also 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. iykyk. ๐Ÿ“Ž

๐ŸŽ€ SEE ALSO ๐ŸŽ€


โญ KEYWORDS โญ

checksum, cksum, crc, crc32, cyclic redundancy check, data integrity, security, sum ๐ŸŒˆ


๐Ÿ’œ CATEGORY ๐Ÿ’œ

Hashes, checksums, and encryption ๐Ÿ”


Copyright (c) 2002, Pat Thoyts <patthoyts@users.sourceforge.net>

and that's the whole page, bestie!! this one came from tcllib, version 1.1.3, and it's the sum(n) page โ€” go forth and checksum responsibly. mwah, ily, bye!! ๐Ÿ’–โœจ๐ŸŽ€๐Ÿฆ‹๐ŸŒธ

๐Ÿ“ฆ where this page comes from