sha1(3trf)
β¨ sha1 β the message digest that ate π
okay so bestie, this is sha1(3trf) β the manual page for the sha1 command, which is one of several message digests handed to you by the trf package. wanna know the whole package vibe? go read trf-intro. π¦
πΈ SYNOPSIS
package require Tcl ?8.2?
package require Trf ?2.1.3?
sha1 ?options...? ?data?
π DESCRIPTION
The command sha1 is one of several message digests provided by the package trf. See trf-intro for an overview of the whole package.
sha1 ?options...? ?data?
π the options that only work when you're attached
real talk: the options below are understood by the digest if and only if the digest is attached to a channel. not sure what "attached" means? the IMMEDIATE versus ATTACHED section below has you covered, bestie.
-mode absorb|write|transparentβ this one has to be present, like it's not optional, it's the moment. the argument you hand it decides how the digest behaves in attached mode.
and not just those three exact spellings β all unique abbreviations are recognized too. here's what each one actually means:
absorbβ everything written to the channel gets used to compute the digest value, and then it gets passed through unchanged to the next level in the stack of transformations for the channel the digest is attached to. when the channel gets closed, the finished digest is written out too β so basically you're attaching the value of the digest after the info that was actually written to the channel. π«Ά
when you're reading from the channel, a digest value gets computed too, and after the channel closes it gets compared against the digest that was attached β i.e. the one that came behind the actual data. you have to specify the -matchflag option so the digest knows where to stash the result of that 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 gets ignored and thrown away. only a value for the digest of the data is computed. when the channel is closed, the computed values get stored as ordered through the options-write-destination,-write-type,-read-destination, and-read-type.transparentβ this mode is a mixture of bothabsorbandwritemodes. likeabsorb, all data β read or written β passes through the digest unchanged. but the generated values for the digest get handled the same way as forwrite.
-matchflagvarname β this option can be used if and only if the option-mode absorbis 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. and heads up: the option gets ignored if the channel is write-only, because in that case there's no comparison of digest values happening at all. π-write-typevariable|channel β this one can be used for digests in modewriteortransparent. 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 tovariable.-read-typevariable|channel β like option-write-type, but for option-read-destination. π«-write-destinationdata β this option can be used for digests in modewriteortransparent. the value data is either the name of a global (or namespaced) variable, or the handle of a writable channel, depending on the value of option-write-type. the message digest computed for data written to the attached channel gets 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 undertcl7.6, due to embedded\0's. no cap, watch out.
-read-destinationdata β this option can be used for digests in modewriteortransparent. the value data is either the name of a global (or namespaced) variable, or the handle of a writable channel, depending on the value of option-read-type. the message digest computed for data read from the attached channel gets written into it after the attached channel was closed. the option is ignored if the channel is write-only.
β οΈ same warning, bestie: using a variable may yield incorrect results undertcl7.6, due to embedded\0's.
π the options that always work, attached or not
these ones are always understood by the digest β attached versus immediate genuinely does not matter. see the IMMEDIATE versus ATTACHED section for explanations of those two terms. π
-attachchannel β whether this option is there or not determines the main operation mode of the transformation.
if it's present, the transformation gets stacked onto the channel whose handle was given to the option and runs in attached mode. more about this in the IMMEDIATE versus ATTACHED section.
if it's absent, the transformation is used in immediate mode and the options listed below are recognized. more about this in the IMMEDIATE versus ATTACHED section.
-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. β¨
π¦ IMMEDIATE VERSUS ATTACHED
the transformation distinguishes between two main ways of using it. these are the immediate and attached operation modes. vibe check on both:
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 gets modified by it according to the definition above. this attachment can be revoked by executing the command unstack for the chosen channel. that is literally the only way to do this at the Tcl level. π
in the second mode, which you can detect 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. iconic behavior 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, back when Tcl version 7.6 was current β because that version and earlier ones had trouble dealing with \0 characters embedded into either input or output. so yeah, it's giving legacy code, but it's our legacy code. π«Ά
π SEE ALSO
adler, crc, crc-zlib, haval, md2, md5, md5_otp, ripemd-128, ripemd-160, sha, sha1, sha1_otp, trf-intro
π₯ KEYWORDS
authentication, hash, hashing, mac, message digest, sha1
π COPYRIGHT
Copyright (c) 1996-2003, Andreas Kupries <andreas_kupries@users.sourceforge.net>
and that's the whole page, bestie!! π this was sha1(3trf) from the Trf transformer commands, version 2.1.3, with the copyright living in that 1996-2003 window. slay, go hash something responsibly. π
β¨
π¦ 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