sha1 - SHA1 Message-Digest Algorithm
TABLE OF CONTENTS
SYNOPSIS
DESCRIPTION
COMMANDS
PROGRAMMING INTERFACE
EXAMPLES
REFERENCES
BUGS, IDEAS, FEEDBACK
SEE ALSO
KEYWORDS
COPYRIGHT
package require Tcl 8.2
package require sha1 ?2.0.3?
This package provides an implementation in Tcl of the SHA1 message-digest algorithm as specified by FIPS PUB 180-1 (1). This algorithm takes a message and generates a 160-bit digest from the input. The SHA1 algorithm is related to the MD4 algorith (2) but has been strengthend against certain types of cryptographic attack. SHA1 should be used in preference to MD4 or MD5 in new applications.
This package also includes support for creating keyed message-digests using the HMAC algorithm from RFC 2104 (3) with SHA1 as the message-digest.
For the programmer, the SHA1 hash can be viewed as a bucket into which one pours data. When you have finished, you extract a value that is derived from the data that was poured into the bucket. The programming interface to the SHA1 hash operates on a token (equivalent to the bucket). You call SHA1Init to obtain a token and then call SHA1Update as many times as required to add data to the hash. To release any resources and obtain the hash value, you then call SHA1Final. An equivalent set of functions 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. Failing that if you have the Trf package then this can be used otherwise there is a pure-tcl equivalent. The programming interface remains the same in all cases.
% sha1::sha1 "Tcl does SHA1" 285a6a91c45a9066bf39fcf24425796ef0b2a8bf |
% sha1::hmac Sekret "Tcl does SHA1" ae6251fa51b95b18cba2be95eb031d07475ff03c |
% set tok [sha1::SHA1Init] ::sha1::1 % sha1::SHA1Update $tok "Tcl " % sha1::SHA1Update $tok "does " % sha1::SHA1Update $tok "SHA1" % sha1::Hex [md5::MD5Final $tok] 285a6a91c45a9066bf39fcf24425796ef0b2a8bf |
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category sha1 of the Tcllib SF Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.
md4, md5, ripemd128, ripemd160
FIPS 180-1, hashing, message-digest, rfc 2104, security, sha1
Copyright © 2005, Pat Thoyts <patthoyts@users.sourceforge.net>