blob: 1b1ce5077a39be4af92b963ab4ceabe3a6f3c65d [file] [log] [blame]
Fred Drake957ac3f1999-04-23 21:52:18 +00001\section{\module{sha} ---
2 SHA message digest algorithm}
3
4\declaremodule{builtin}{sha}
5\modulesynopsis{NIST's secure hash algorithm, SHA.}
6\sectionauthor{Fred L. Drake, Jr.}{fdrake@acm.org}
7
8
9This module implements the interface to NIST's\index{NIST} secure hash
10algorithm,\index{Secure Hash Algorithm} known as SHA. It is used in
11the same way as the \refmodule{md5} module:\ use the \function{new()}
12to create an sha object, then feed this object with arbitrary strings
13using the \method{update()} method, and at any point you can ask it
14for the \dfn{digest} of the contatenation of the strings fed to it
15so far.\index{checksum!SHA} SHA digests are 160 bits instead of 128
16bits.
17
18
19\begin{funcdesc}{new}{\optional{string}}
20 Return a new sha object. If \var{string} is present, the method
21 call \code{update(\var{string})} is made.
22\end{funcdesc}
23
24
25The following values are provided as constants in the module and as
26attributes of the sha objects returned by \function{new()}:
27
28\begin{datadesc}{blocksize}
29 Size of the blocks fed into the hash function; this is always
30 \code{1}. This size is used to allow an arbitrary string to be
31 hashed.
32\end{datadesc}
33
34\begin{datadesc}{digestsize}
35 The size of the resulting digest in bytes. This is always
36 \code{20}.
37\end{datadesc}
38
39
40A sha object has all the methods the md5 objects have, plus one:
41
42\begin{methoddesc}[sha]{hexdigest}{}
43 Return the digest value as a string of hexadecimal digits. This may
44 be used to exchange the value safely in email or other non-binary
45 environments.
46\end{methoddesc}
47
48
49\begin{seealso}
50 \seetext{The Secure Hash Algorithm is defined by NIST document FIPS
Fred Drake356d0ce1999-11-09 20:10:01 +000051 PUB 180-1: \citetitle{Secure Hash Standard}, published in April
Fred Drake957ac3f1999-04-23 21:52:18 +000052 of 1995. It is available online as plain text at
53 \url{http://csrc.nist.gov/fips/fip180-1.txt} (at least one
54 diagram was omitted) and as PostScript at
55 \url{http://csrc.nist.gov/fips/fip180-1.ps}.}
56\end{seealso}