md2(3trf)

✨ NAME ✨

md2 β€” the message digest called "md2", bestie πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

package require Tcl  ?8.2?

package require Trf  ?2.1.3?

md2 ?options...? ?data?

πŸ’… DESCRIPTION πŸ’…

So the command md2 is literally one of several message digests that the package trf hands out. If you wanna see the whole squad at once, go read trf-intro for the overview of the entire package. iykyk πŸ¦‹

md2 ?options...? ?data?

The options down below are understood by the digest if and only if the digest is attached to a channel. (If you're like "attached???" β€” run, don't walk, to the section IMMEDIATE versus ATTACHED, it explains the whole term.)

  • -mode absorb|write|transparent β€” okay this one has to be present, no skipping it. Whatever you pass in decides how the digest behaves in attached mode. And not just those exact words β€” all unique abbreviations are recognized too. Meaning of each, coming right up:
    • absorb β€” every bit of 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 gets closed, the completed digest is written out too β€” so basically the digest value gets attached after the info that was actually written to the channel. And when you're reading from the channel, a digest value gets computed too, and after the channel closes it gets compared to the digest that was attached, i.e. the one that came behind the actual data. For that, the option -matchflag has to be specified, 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 is ignored and thrown away, periodt. 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 little mixture of both absorb and write. Like with absorb, all data, read or written, passes through the digest unchanged. But the generated values for the digest get handled the same way as in write.
  • -matchflag varname β€” this one 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. And ngl, the option gets ignored if the channel is write-only, because in that case there will be no comparison of digest values at all. πŸ™ˆ
  • -write-type variable|channel β€” usable for digests in mode write or transparent. And beyond those two values, all their unique abbreviations are allowed as argument values too. This option decides the type of the argument to option -write-destination. It defaults to variable.
  • -read-type variable|channel β€” same energy as option -write-type, but for option -read-destination. ✨
  • -write-destination data β€” usable 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, 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.
Heads up bestie: using a variable may yield incorrect results under tcl 7.6, due to embedded \0's. 😭
  • -read-destination data β€” usable 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, 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, same vibe: 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. (Again, the section IMMEDIATE versus ATTACHED explains those two terms.)

  • -attach channel β€” the presence/absence of this option is what determines the main operation mode of the transformation. No pressure or anything. πŸ‘‘
    • If it's present, the transformation gets stacked onto the channel whose handle was given to the option, and it runs in attached mode. More on this in the section IMMEDIATE versus ATTACHED.
    • If it's absent, the transformation is used in immediate mode, and the options listed below are recognized. More on this in the section IMMEDIATE versus ATTACHED.
  • -in channel β€” this option is legal if and only if the transformation is used in immediate mode. It gives you 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. 🌸
  • -out channel β€” this option is legal if and only if the transformation is used in immediate mode. It gives you the handle of the channel the generated transformation result gets 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. slay πŸ’–

🌈 IMMEDIATE VERSUS ATTACHED 🌈

The transformation lowkey distinguishes between two main ways of using it. They're the immediate and attached operation modes. Two whole personalities fr fr.

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 itself gets changed in such a way that from then on, all data written to it 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. And that is 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 the 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. One thing to note: this ability to immediately read from and/or write to a channel is a historic artifact which was introduced at the beginning of Trf's life, back when Tcl version 7.6 was current, because this and earlier versions have trouble dealing with \0 characters embedded into either input or output. πŸ‘‘πŸ’€


πŸ¦‹ 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, md2, message digest


Copyright (c) 1996-2003, Andreas Kupries <andreas_kupries@users.sourceforge.net>


okay that's the whole thing, bestie β€” this one's from the Trf transformer commands, version 2.1.3, and it's the md2(3trf) page. go forth and hash responsibly πŸ§šβ­πŸ’–

πŸ“¦ where this page comes from