blob: 29e4b31c097191843acf4515979dfe7c5ffc23c0 [file] [log] [blame]
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00001\section{Built-in module \sectcode{md5}}
2\bimodindex{md5}
3
4This module implements the interface to RSA's MD5 message digest
5algorithm (see also the file \file{md5.doc}). It's use is very
6straightforward: use the function \code{md5} to create an
7\dfn{md5}-object. You can now ``feed'' this object with arbitrary
8strings.
9
10At any time you can ask the ``final'' digest of the object. Internally,
11a temorary copy of the object is made and the digest is computed and
12returned. Because of the copy, the digest operation is not desctructive
13for the object. Before a more exact description of the use, a small
14example: to obtain the digest of the string \code{'abc'}, use \ldots
15
16\bcode\begin{verbatim}
17>>> from md5 import md5
18>>> m = md5()
19>>> m.update('abc')
20>>> m.digest()
21'\220\001P\230<\322O\260\326\226?}(\341\177r'
22\end{verbatim}\ecode
23
24More condensed:
25
26\bcode\begin{verbatim}
27>>> md5('abc').digest()
28'\220\001P\230<\322O\260\326\226?}(\341\177r'
29\end{verbatim}\ecode
30
31\renewcommand{\indexsubitem}{(in module md5)}
32\begin{funcdesc}{md5}{arg}
33 Create a new md5-object. \var{arg} is optional: if present, an initial
34 \code{update} method is called with \var{arg} as argument.
35\end{funcdesc}
36
37An md5-object has the following methods:
38
39\renewcommand{\indexsubitem}{(md5 method)}
40\begin{funcdesc}{update}{arg}
41 Update this md5-object with the string \var{arg}.
42\end{funcdesc}
43
44\begin{funcdesc}{digest}{}
45 Return the \dfn{digest} of this md5-object. Internally, a copy is made
46 and the \C-function \code{MD5Final} is called. Finally the digest is
47 returned.
48\end{funcdesc}
49
50\begin{funcdesc}{copy}{}
51 Return a separate copy of this md5-object. An \code{update} to this
52 copy won't affect the original object.
53\end{funcdesc}