ripemd160(3tcl)
π ripemd160 π
okay so bestie, you've wandered into the ripemd160 corner of the tcllib docs (that's the manual page name, ripemd160(3tcl), in case you were wondering what you clicked) β and honestly? iconic. this is the RIPEMD-160 Message-Digest Algorithm, and we're gonna get you fluent in it. grab a boba. π§β¨
πΈ 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
π¦ DESCRIPTION π¦
so this package is a Tcl implementation of the RIPEMD-160 message-digest algorithm (that's reference (1), keep scrolling). what does it do? it takes a literally arbitrary quantity of data and spits out a 160-bit message digest from that input. the RIPEMD-160 algorithm is based on the MD4 algorithm (refs (2) and (4), bestie, they're both cited) but it's been cryptographically strengthened against the weaknesses that got found in MD4 (that's (4) again). glow-up, honestly. π
and here's a lil performance tea: this package will use cryptkit or Trf to accelerate the digest computation if either package is available. if neither accelerator is around? the pure-Tcl implementation gets used instead. no biggie, just slower. π
BEWARE π the commands in this package expect binary data as their input. when a-fileis provided, the commands themselves make sure of that, because they open the referenced file in binary mode. but when literal data, or a-channel, are provided instead β then it's on the caller to make sure that's the case. the necessary conversion command is:encoding convertto utf-8 $string
ATTENTION π¨ there is a Tcl 9 COMPATIBILITY ISSUE here. Tcl 8.x 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 wrong. π Tcl 9 throws an error instead, i.e. expected byte sequence but character <location> was ...
π COMMANDS π
::ripemd::ripemd160 ?-hex? [ -channel channel | -file filename | string ]β calculates the RIPEMD-160 digest of the data given in string. by default it comes back as a binary string. pass the-hexoption and you get a hexadecimal encoded version of the digest instead. π
the data to be hashed can be given either as a string argument to the ripemd160 command, or as a filename, or as a pre-opened channel. if -filename is given then the file is opened, the data read and hashed, and the file is closed. if -channel is given then data is read from the channel until the end of file, and the channel is not closed. β¨
only one of-file,-channelor string should be given. pick a lane, babe.
::ripemd::hmac160 ?-hex? -key key [ -channel channel | -file filename | string ]β calculates a Hashed Message Authentication digest (HMAC) using the RIPEMD-160 digest algorithm. HMACs are described in RFC 2104 (ref (5)) and they give you a RIPEMD-160 digest that includes a key π. every option other than-keyworks exactly like it does for the::ripemd::ripemd160command.
π PROGRAMMING INTERFACE π
for the programmer girlies: think of hash functions as a bucket you pour data into πͺ£. when you're done pouring, you extract a value that's uniquely derived from everything that went in. the programming interface to the hash works on a token (the token is the bucket, basically). you call RIPEMD160Init to get a token, then call RIPEMD160Update as many times as you need to add data to the hash. then, to release any resources and get the hash value, you call RIPEMD160Final. there's an equivalent set of functions that gives you a keyed digest (HMAC). π«Ά
::ripemd::RIPEMD160Initβ begins a new RIPEMD-160 hash. returns a token ID that you must use for the remaining functions.::ripemd::RIPEMD160Update token dataβ adds data to the hash identified by token. callingRIPEMD160Update $token "abcd"is equivalent to callingRIPEMD160Update $token "ab"followed byRIPEMD160Update $token "cb". see EXAMPLES below π::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::ripemd::RIPEHMAC160Final tokenβ these commands are identical to theRIPEMD160equivalent commands.
π EXAMPLES π
watch this, it's giving effortless:
% 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 updates land on the exact same digest? that's the whole "abcd" = "ab" + "cb" thing in action. no cap. π₯
π 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 β will undoubtedly contain bugs and other problems. π please report such in the category ripemd of the Tcllib Trackers at 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 love feedback, fr fr.
when proposing code changes, please provide unified diffs, i.e the output of diff -u.
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. β¨
β 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 bestie, that's the whole page, you ate it π«Ά this was tcllib version 1.0.7 of the ripemd160(3tcl) manual, so go hash something and stay iconic. mwah. π β¨π
π¦ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- 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