crc(3trf)
π crc β message digest "crc" π
okay bestie, welcome to crc(3trf), the manual page for the crc message digest β¨ this one lives in the trf family and it's lowkey iconic, let's get into it π«Ά
β¨ SYNOPSIS β¨
package require Tcl ?8.2?
package require Trf ?2.1.3?
crc ?options...? ?data?
πΈ DESCRIPTION πΈ
So crc is one of the several message digests that the package trf gives you. If you want the whole vibe check on the package, go read trf-intro β it's the overview of everything π
crc ?options...? ?data?
okay so the options below? they're understood by the digest if and only if the digest is attached to a channel. not sure what "attached" means? no worries, there's a whole section called IMMEDIATE versus ATTACHED that explains the term, we got you π§
-modeabsorb|write|transparent β bestie this one has to be present, like it's not optional, it's the moment. The argument you give it decides how the digest behaves in attached mode. Beyond the three values listed above, all unique abbreviations are recognized too. Here's what they mean:- absorb β all the data written to the channel gets used to calculate the value of the message digest, and then it's passed unchanged to the next level in the stack of transformations for the channel the digest is attached to. When the channel is closed the completed digest is written out too, essentially attaching the value of the digest after the information actually written to the channel. When you're reading from the channel, a value for the digest is computed too, and after the channel is closed it gets compared to the digest which was attached, i.e. came behind the actual data. The option
-matchflaghas to be specified so that the digest knows where to store the result of said comparison. That result is a string, and it's either"ok", or"failed". - write β all data read from or written to the channel the digest is attached to is ignored and thrown away π only a value for the digest of the data is computed. When the channel is closed the computed values are stored as ordered through the options
-write-destination,-write-type,-read-destination, and-read-type. - transparent β this mode is a mixture of both absorb and write modes. As for absorb, all data, read or written, passes through the digest unchanged. The generated values for the digest however are handled in the same way as for write.
- absorb β all the data written to the channel gets used to calculate the value of the message digest, and then it's passed unchanged to the next level in the stack of transformations for the channel the digest is attached to. When the channel is closed the completed digest is written out too, essentially attaching the value of the digest after the information actually written to the channel. When you're reading from the channel, a value for the digest is computed too, and after the channel is closed it gets compared to the digest which was attached, i.e. came behind the actual data. The option
-matchflagvarname β this option can be used if and only if the option"-mode absorb"is present. In that situation the argument is the name of a global or namespaced variable. The digest will write the result of comparing two digest values into this variable. The option will be ignored if the channel is write-only, because in that case there will be no comparison of digest values.-write-typevariable|channel β this option can be used for digests in mode write or transparent. Beyond the values listed above, all their unique abbreviations are also allowed as argument values. The option determines the type of the argument to option-write-destination. It defaults to variable.-read-typevariable|channel β like option-write-type, but for option-read-destination.-write-destinationdata β this option can be used for digests in mode write or transparent. The value data is either the name of a global (or namespaced) variable or the handle of a writable channel, dependent on the value of option-write-type. The message digest computed for data written to the attached channel is written into it after the attached channel was closed. The option is ignored if the channel is read-only.
Note that using a variable may yield incorrect results under tcl 7.6, due to embedded \0's. π
-read-destinationdata β this option can be used for digests in mode write or transparent. The value data is either the name of a global (or namespaced) variable or the handle of a writable channel, dependent on the value of option-read-type. The message digest computed for data read from the attached channel is written into it after the attached channel was closed. The option is ignored if the channel is write-only.
Note that using a variable may yield incorrect results under tcl 7.6, due to embedded \0's. π
the options listed below are always understood by the digest, attached versus immediate does not matter, periodt. See section IMMEDIATE versus ATTACHED for explanations of these two terms π
-attachchannel β the presence/absence of this option determines the main operation mode of the transformation.
If present, the transformation will be stacked onto the channel whose handle was given to the option and run in attached mode. More about this in section IMMEDIATE versus ATTACHED.
If the option is absent, the transformation is used in immediate mode and the options listed below are recognized. More about this in section IMMEDIATE versus ATTACHED.
-inchannel β this option is legal if and only if the transformation is used in immediate mode. It provides the handle of the channel the data to transform has to be read from.
If the transformation is in immediate mode and this option is absent, the data to transform is expected as the last argument to the transformation.
-outchannel β this option is legal if and only if the transformation is used in immediate mode. It provides the handle of the channel the generated transformation result is written to.
If the transformation is in immediate mode and this option is absent, the generated data is returned as the result of the command itself.
π NOTES π
This command uses the same CRC polynomial as the CRC algorithm used by PGP (http://www.pgp.com). no cap π«Ά
π¦ IMMEDIATE VERSUS ATTACHED π¦
The transformation distinguishes between two main ways of using it. These are the immediate and attached operation modes. two modes, two vibes, one icon π
For the attached mode the option -attach is used to associate the transformation with an existing channel. During the execution of the command no transformation is performed, instead the channel is changed in such a way, that from then on all data written to or read from it passes through the transformation and is modified by it according to the definition above. This attachment can be revoked by executing the command unstack for the chosen channel. This is the only way to do this at the Tcl level. fr fr, that's the only way.
In the second mode, which can be detected by the absence of option -attach, the transformation immediately takes data from either its commandline or a channel, transforms it, and returns the result either as result of the command, or writes it into a channel. The mode is named after the immediate nature of its execution. main character energy honestly β¨
Where the data is taken from, and delivered to, is governed by the presence and absence of the options -in and -out. It should be noted that this ability to immediately read from and/or write to a channel is an historic artifact which was introduced at the beginning of Trf's life when Tcl version 7.6 was current, as this and earlier versions have trouble to deal with \0 characters embedded into either input or output. π classic
π SEE ALSO π
adlercrccrc-zlibhavalmd2md5md5_otpripemd-128ripemd-160shasha1sha1_otptrf-intro
β KEYWORDS β
authentication, crc, hash, hashing, mac, message digest, pgp
π COPYRIGHT π
Copyright (c) 1996-2003, Andreas Kupries <andreas_kupries@users.sourceforge.net>
and that's the whole page bestie π this lil manual comes to you from the Trf transformer commands, version 2.1.3, living its life as crc(3trf) β slay, go hash something πβ¨πΈ
π¦ where this page comes from
- debian bookworm: tcl-trf-doc 2.1.4-dfsg3-2.1
- debian trixie: tcl-trf-doc 2.1.4-dfsg3-8
- ubuntu jammy: tcl-trf-doc 2.1.4-dfsg3-2.1build1
- ubuntu noble: tcl-trf-doc 2.1.4-dfsg3-3
- ubuntu questing: tcl-trf-doc 2.1.4-dfsg3-8
- ubuntu resolute: tcl-trf-doc 2.1.4-dfsg3-8build1
- ubuntu stonking: tcl-trf-doc 2.1.4-dfsg3-9build1
- Copyright (c) 1996-2003, Andreas Kupries <andreas_kupries@users.sourceforge.net>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms