ripemd160(n) | RIPEMD Message-Digest Algorithm | ripemd160(n) |
ripemd160 - RIPEMD-160 Message-Digest Algorithm
package require Tcl 8.2
package require ripemd160 ?1.0.3?
::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
This package is an implementation in Tcl of the RIPEMD-160 message-digest algorithm (1). This algorithm takes an arbitrary quantity of data and generates a 160-bit message digest from the input. The RIPEMD-160 algorithm is based upon the MD4 algorithm (2, 4) but has been cryptographically strengthened against weaknesses that have been found in MD4 (4).
This package will use cryptkit or Trf to accelerate the digest computation if either package is available. In the absence of an accelerator package the pure-Tcl implementation will be used.
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 end of file. The channel is not closed.
Only one of -file, -channel or string should be given.
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 uniquely derived 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 keyed digest (HMAC).
% 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
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category ripemd of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation.
md4, md5, ripemd128, sha1
RIPEMD, hashing, md4, message-digest, rfc 1320, rfc 1321, rfc 2104, security
Hashes, checksums, and encryption
Copyright (c) 2004, Pat Thoyts <patthoyts@users.sourceforge.net>
1.0.3 | ripemd |