ripemd160(n)
π ripemd160 β the RIPEMD Message-Digest Algorithm π
okay bestie, so this is the manual page for ripemd160, a Tcl package living in tcllib (we're at version 1.0.7, iykyk). It's giving crypto, it's giving hashing, and we're gonna get through every single line of it together. Grab a snack. π
β¨ NAME β¨
ripemd160 β RIPEMD-160 Message-Digest Algorithm
πΈ SYNOPSIS πΈ
package require Tcl 8.5 9
package require ripemd160 ?1.0.7?
::ripemd::ripemd160 ?-hex? [ -channel channel | -file filename | string ]
::ripemd::hmac160 ?-hex? -key key [ -channel channel | -file filename | string ]
::ripemd::RIPEMD160Init
::ripemd::RIPEMD160Update token data
::ripemd::RIPEMD160Final token
::ripemd::RIPEHMAC160Init key
::ripemd::RIPEHMAC160Update token data
::ripemd::RIPEHMAC160Final token
look at all those little guys. we love a full command roster. π
π DESCRIPTION π
So this package is a Tcl implementation of the RIPEMD-160 message-digest algorithm (that's reference (1), bestie). What does that even mean? It means you hand it an arbitrary quantity of data β as much as you want, no cap β and it hands you back a 160-bit message digest generated from that input. β¨
The RIPEMD-160 algorithm is based upon the MD4 algorithm (2, 4), but it's been cryptographically strengthened against the weaknesses that got found in MD4 (4). So it's MD4's glow-up era. π
Also, sneaky speed hack: this package will use cryptkit or Trf to accelerate the digest computation if either package is available. If neither accelerator is around? No worries, the pure-Tcl implementation steps in and handles it. π«Ά
BEWARE π The commands in this package expect <strong>binary data</strong> as their input. When a-fileis provided, this is ensured by the commands themselves, because they open the referenced file in <strong>binary mode</strong>. But when literal data, or a-channel, is provided instead, then <strong>the command's caller is responsible</strong> for ensuring this fact. The necessary conversion command isencoding convertto utf-8 $string.
ATTENTION π¨ there is a <strong>Tcl 9 COMPATIBILITY ISSUE</strong> here. <strong>Tcl 8.x</strong> silently mishandles non-binary input by cutting it internally to size. I.e. by only using the low byte of a higher unicode point. No error is thrown, the result is simply <em>wrong</em>. π <strong>Tcl 9</strong> throws an error instead, i.e. expected byte sequence but character <location> was ...
fr fr, know which Tcl you're on. π
π COMMANDS π
::ripemd::ripemd160 ?-hex? [ -channel channel | -file filename | string ]β Calculate the RIPEMD-160 digest of the data given in string. This is returned as a binary string by default. Giving the-hexoption will return a hexadecimal encoded version of the digest.
The data to be hashed can be specified either as a string argument to the ripemd160 command, or as a filename or a pre-opened channel. If the -filename argument is given then the file is opened, the data read and hashed and the file is closed. If the -channel argument is given then data is read from the channel until the <strong>end of file</strong>. The channel is <strong>not</strong> closed.
Only <strong>one</strong> of -file, -channel or string should be given. pick one bestie, don't be greedy. π
::ripemd::hmac160 ?-hex? -key key [ -channel channel | -file filename | string ]β Calculate a Hashed Message Authentication digest (HMAC) using the RIPEMD-160 digest algorithm. HMACs are described in RFC 2104 (5) and provide a RIPEMD-160 digest that <strong>includes a key</strong>. All options other than-keyare exactly as for the::ripemd::ripemd160command. π
π¦ PROGRAMMING INTERFACE π¦
For the programmer, hash functions can be viewed as a bucket into which one pours data. When you have finished, you extract a value that is <strong>uniquely derived</strong> from the data that was poured into the bucket. The programming interface to the hash operates on a token (equivalent to the bucket). You call RIPEMD160Init to obtain a token and then call RIPEMD160Update as many times as required to add data to the hash. To release any resources and obtain the hash value, you then call RIPEMD160Final. An equivalent set of functions gives you a <strong>keyed</strong> digest (HMAC). β¨
::ripemd::RIPEMD160Initβ Begins a new RIPEMD-160 hash. Returns a token ID that must be used for the remaining functions.::ripemd::RIPEMD160Update token dataβ Add data to the hash identified by token. CallingRIPEMD160Update $token "abcd"is equivalent to callingRIPEMD160Update $token "ab"followed byRIPEMD160Update $token "cb". See EXAMPLES. π§::ripemd::RIPEMD160Final tokenβ Returns the hash value and releases any resources held by this token. Once this command completes the token will be invalid. The result is a binary string of 16 bytes representing the 160 bit RIPEMD-160 digest value.::ripemd::RIPEHMAC160Init keyβ This is equivalent to the::ripemd::RIPEMD160Initcommand except that it requires the key that will be included in the HMAC. π::ripemd::RIPEHMAC160Update token dataβ (no extra description, she's just here)::ripemd::RIPEHMAC160Final tokenβ These commands are identical to theRIPEMD160equivalent commands. π―
π EXAMPLES π
watch this, it's so satisfying:
% ripemd::ripemd160 -hex "Tcl does RIPEMD-160"
0829dea75a1a7074c702896723fe37763481a0a7
% ripemd::hmac160 -hex -key Sekret "Tcl does RIPEMD-160"
bf0c927231733686731dddb470b64a9c23f7f53b
% set tok [ripemd::RIPEMD160Init]
::ripemd::1
% ripemd::RIPEMD160Update $tok "Tcl "
% ripemd::RIPEMD160Update $tok "does "
% ripemd::RIPEMD160Update $tok "RIPEMD-160"
% ripemd::Hex [ripemd::RIPEMD160Final $tok]
0829dea75a1a7074c702896723fe37763481a0a7
see how the chunked update lands on the exact same digest as the one-shot call? that's the whole point, main character consistency. π
β REFERENCES β
- H. Dobbertin, A. Bosselaers, B. Preneel, "RIPEMD-160, a strengthened version of RIPEMD"
http://www.esat.kuleuven.ac.be/~cosicart/pdf/AB-9601/AB-9601.pdf - Rivest, R., "The MD4 Message Digest Algorithm", RFC 1320, MIT, April 1992. (
http://www.rfc-editor.org/rfc/rfc1320.txt) - Rivest, R., "The MD4 message digest algorithm", in A.J. Menezes and S.A. Vanstone, editors, Advances in Cryptology - CRYPTO '90 Proceedings, pages 303-311, Springer-Verlag, 1991.
- Dobbertin, H., "Cryptanalysis of MD4", Journal of Cryptology vol 11 (4), pp. 253-271 (1998)
- Krawczyk, H., Bellare, M. and Canetti, R. "HMAC: Keyed-Hashing for Message Authentication", RFC 2104, February 1997. (
http://www.rfc-editor.org/rfc/rfc2104.txt)
π BUGS, IDEAS, FEEDBACK π
ngl, this document, and the package it describes, <strong>will undoubtedly contain bugs and other problems</strong>. Please report such in the category ripemd of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please also report any ideas for enhancements you may have for either the package and/or the documentation. we're listening fr. π«Ά
When proposing code changes, please provide <strong>unified diffs</strong>, i.e the output of diff -u.
Note further that <strong>attachments are strongly preferred over inlined patches</strong>. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the <strong>left-most button</strong> in the secondary navigation bar. π
πΈ SEE ALSO πΈ
md4, md5, ripemd128, sha1
π KEYWORDS π
RIPEMD, hashing, md4, message-digest, rfc 1320, rfc 1321, rfc 2104, security
π§ CATEGORY π§
Hashes, checksums, and encryption
π COPYRIGHT π
Copyright (c) 2004, Pat Thoyts <patthoyts@users.sourceforge.net>
okay that's the whole page, bestie, every flag and every footnote accounted for π and just so you know, this little beauty ships as part of tcllib, version 1.0.7, filed under ripemd160(n). slay, stay hashed, and remember: binary input only, or Tcl 9 will <em>drag</em> you. β¨π¦π
π¦ where this page comes from
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- Copyright (c) 2004, Pat Thoyts <patthoyts@users\&.sourceforge\&.net>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms