Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 1 | \section{Built-in module \sectcode{md5}} |
| 2 | \bimodindex{md5} |
| 3 | |
| 4 | This module implements the interface to RSA's MD5 message digest |
| 5 | algorithm (see also the file \file{md5.doc}). It's use is very |
| 6 | straightforward: use the function \code{md5} to create an |
| 7 | \dfn{md5}-object. You can now ``feed'' this object with arbitrary |
| 8 | strings. |
| 9 | |
| 10 | At any time you can ask the ``final'' digest of the object. Internally, |
| 11 | a temorary copy of the object is made and the digest is computed and |
| 12 | returned. Because of the copy, the digest operation is not desctructive |
| 13 | for the object. Before a more exact description of the use, a small |
| 14 | example: 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 | |
| 24 | More 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 | |
| 37 | An 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} |