ripemd128(3tcl)

πŸ“¦
version 2.0 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– ripemd128 πŸ’–

okay bestie, welcome to the ripemd128 manual page, from the Tcllib fam β€” manual section 3tcl, iykyk. this is the RIPEMD-128 Message-Digest Algorithm page and it's genuinely iconic, so let's get into it πŸŽ€


✨ NAME ✨

ripemd128 β€” the RIPEMD-128 Message-Digest Algorithm, fr fr 🌸


✨ SYNOPSIS ✨

package require Tcl 8.5 9

package require ripemd128 ?1.0.6?

::ripemd::ripemd128  ?-hex? [ -channel channel | -file filename | string
]

::ripemd::hmac128 ?-hex? -key key [ -channel channel | -file filename  |
string ]

::ripemd::RIPEMD128Init

::ripemd::RIPEMD128Update token data

::ripemd::RIPEMD128Final token

::ripemd::RIPEHMAC128Init key

::ripemd::RIPEHMAC128Update token data

::ripemd::RIPEHMAC128Final token

✨ DESCRIPTION ✨

so this package is a Tcl implementation of the RIPEMD-128 message-digest algorithm (1). it takes literally any amount of data β€” arbitrary quantity, no cap β€” and spits out a 128-bit message digest from whatever you fed it. πŸ’…

RIPEMD-128 is based on the MD4 algorithm (2, 4), but it got cryptographically strengthened against the weaknesses people found in MD4 (4). and the glow-up doesn't stop there: RIPEMD-128 was designed to be a drop-in replacement for MD4 and MD5 (5). but listen β€” if security is the major consideration, then RIPEMD-160 or SHA1 should be considered. that's not me being dramatic, that's the page. πŸ”₯

this package will use Trf to accelerate the digest computation if it's available. no accelerator package? no problem, the pure-Tcl implementation steps in. main character energy either way. πŸ‘‘

BEWARE 🚨 the commands in this package expect binary data as their input. when a -file is provided, the commands themselves ensure this β€” they open the referenced file in binary mode, slay. but when literal data, or a -channel, is provided instead, then the command's caller is responsible for ensuring this fact. the necessary conversion command is encoding convertto utf-8 $string. don't skip this, bestie. πŸ™ˆ

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. literally wrong and it won't even tell you.
  • Tcl 9 throws an error instead, i.e.
expected byte sequence but character <location> was ...

✨ COMMANDS ✨

  • ::ripemd::ripemd128 ?-hex? [ -channel channel | -file filename | string ] β€” calculate the RIPEMD-128 digest of the data given in string. by default it comes back as a binary string. give it the -hex option and you get a hexadecimal encoded version of the digest instead. ✨

the data to be hashed can be specified either as a string argument to the ripemd128 command, or as a filename, or as 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 end of file β€” and heads up, the channel is not closed. 🫢

only one of -file, -channel or string should be given. pick a lane bestie πŸ’…

  • ::ripemd::hmac128 ?-hex? -key key [ -channel channel | -file filename | string ] β€” calculate a Hashed Message Authentication digest (HMAC) using the RIPEMD-128 digest algorithm. HMACs are described in RFC 2104 (6) and they give you a RIPEMD-128 digest that includes a key. every option other than -key works exactly like it does for the ::ripemd::ripemd128 command. πŸ”

✨ PROGRAMMING INTERFACE ✨

for the programmer, hash functions can be viewed as a bucket into which one pours data. when you're done, you extract a value that is uniquely derived from the data that got poured into the bucket. the programming interface to the hash operates on a token (which is basically the bucket, iconic metaphor, no notes). you call RIPEMD128Init to obtain a token, then call RIPEMD128Update as many times as you need to add data to the hash. to release any resources and obtain the hash value, you then call RIPEMD128Final. and there's an equivalent set of functions that gives you a keyed digest (HMAC). 🌈

if you have critcl and have built the tcllibc package, then the implementation of the hashing function will be performed by compiled code. alternatively, if both the Trf and Memchan extensions are available then those will be used. finally the package will revert to a pure-Tcl implementation. the programming interface remains the same, however. so your code doesn't have to care. πŸ’œ

  • ::ripemd::RIPEMD128Init β€” begins a new RIPEMD-128 hash. returns a token ID that must be used for the remaining functions.
  • ::ripemd::RIPEMD128Update token data β€” add data to the hash identified by token. calling RIPEMD128Update $token "abcd" is equivalent to calling RIPEMD128Update $token "ab" followed by RIPEMD128Update $token "cb". see EXAMPLES below ✨
  • ::ripemd::RIPEMD128Final 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 128 bit RIPEMD-128 digest value. πŸŽ€
  • ::ripemd::RIPEHMAC128Init key β€” this is equivalent to the ::ripemd::RIPEMD128Init command, except that it requires the key that will be included in the HMAC.
  • ::ripemd::RIPEHMAC128Update token data
  • ::ripemd::RIPEHMAC128Final token β€” these commands are identical to the RIPEMD128 equivalent commands. same energy, keyed edition. πŸ”‘

✨ EXAMPLES ✨

look at these, they ate πŸ“

% ripemd::ripemd128 -hex "Tcl does RIPEMD-128"
3cab177bae65205d81e7978f63556c63

% ripemd::hmac128 -hex -key Sekret "Tcl does RIPEMD-128"
b359dc5971a05beea0be7b106b30e389

% set tok [ripemd::RIPEMD128Init]
::ripemd::1
% ripemd::RIPEMD128Update $tok "Tcl "
% ripemd::RIPEMD128Update $tok "does "
% ripemd::RIPEMD128Update $tok "RIPEMD-128"
% ripemd::Hex [ripemd::RIPEMD128Final $tok]
3cab177bae65205d81e7978f63556c63

✨ REFERENCES ✨


✨ 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 [http://core.tcl.tk/tcllib/reportlist]. please also report any ideas for enhancements you may have for either package and/or documentation β€” we love ideas, send them. πŸ’–

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. yes, that specific button. the left-most one. go get it bestie. ✨


✨ SEE ALSO ✨

md4, md5, ripemd160, sha1 β€” the whole friend group 🌸


✨ KEYWORDS ✨

RIPEMD, hashing, md4, message-digest, rfc 1320, rfc 1321, rfc 2104, security πŸ”


✨ CATEGORY ✨

Hashes, checksums, and encryption πŸ’…


Copyright (c) 2004, Pat Thoyts <patthoyts@users.sourceforge.net>


and that's the whole page, bestie πŸ¦‹ β€” this was ripemd128 from tcllib, version 1.0.6, and yes that footer really did just say tcllib 1.0.6 ripemd128(3tcl), so now you know. go hash something (in binary mode, please 😭). mwah πŸ’–βœ¨

πŸ“¦ where this page comes from