blob: d8a5c26d3e44ffed08180ea2fea107d618733276 [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
Thomas Woutersf8316632000-07-16 19:01:10 +000014for the \dfn{digest} of the concatenation of the strings fed to it
Fred Drake957ac3f1999-04-23 21:52:18 +000015so 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}
Fred Drakeb9fd4682000-09-14 21:46:22 +000050 \seetitle[http://csrc.nist.gov/fips/fip180-1.txt]{Secure Hash Standard}{
51 The Secure Hash Algorithm is defined by NIST document FIPS
52 PUB 180-1:
53 \citetitle[http://csrc.nist.gov/fips/fip180-1.txt]{Secure
54 Hash Standard}, published in April of 1995. It is
55 available online as plain text (at least one diagram was
Fred Drake91fc9312000-09-16 04:59:33 +000056 omitted) and as PDF at
57 \url{http://csrc.nist.gov/fips/fip180-1.pdf}.}
Fred Drake957ac3f1999-04-23 21:52:18 +000058\end{seealso}