cpython/Doc/libmd5.tex

62 lines
1.9 KiB
TeX
Raw Normal View History

1994-01-01 21:22:07 -04:00
\section{Built-in module \sectcode{md5}}
\bimodindex{md5}
This module implements the interface to RSA's MD5 message digest
algorithm (see also the file \file{md5.doc}). Its use is quite
1995-03-13 06:03:32 -04:00
straightforward:\ use the function \code{new} to create an
1994-01-01 21:22:07 -04:00
\dfn{md5}-object. You can now ``feed'' this object with arbitrary
strings.
At any time you can ask for the ``final'' digest of the object. Internally,
a temporary copy of the object is made and the digest is computed and
returned. Because of the copy, the digest operation is not destructive
for the object. Before a more exact description of the module's use, a small
example will be helpful:
to obtain the digest of the string \code{'abc'}, use \ldots
1994-01-01 21:22:07 -04:00
\bcode\begin{verbatim}
>>> import md5
>>> m = md5.new()
1994-01-01 21:22:07 -04:00
>>> m.update('abc')
>>> m.digest()
'\220\001P\230<\322O\260\326\226?}(\341\177r'
\end{verbatim}\ecode
More condensed:
\bcode\begin{verbatim}
>>> md5.new('abc').digest()
1994-01-01 21:22:07 -04:00
'\220\001P\230<\322O\260\326\226?}(\341\177r'
\end{verbatim}\ecode
\renewcommand{\indexsubitem}{(in module md5)}
\begin{funcdesc}{new}{\optional{arg}}
Create a new md5-object. If \var{arg} is present, an initial
1994-01-01 21:22:07 -04:00
\code{update} method is called with \var{arg} as argument.
\end{funcdesc}
\begin{funcdesc}{md5}{\optional{arg}}
For backward compatibility reasons, this is an alternative name for the
\code{new} function.
\end{funcdesc}
1994-01-01 21:22:07 -04:00
An md5-object has the following methods:
\renewcommand{\indexsubitem}{(md5 method)}
\begin{funcdesc}{update}{arg}
Update this md5-object with the string \var{arg}.
\end{funcdesc}
\begin{funcdesc}{digest}{}
% XXX The following is not quite clear; what does MD5Final do?
1994-01-01 21:22:07 -04:00
Return the \dfn{digest} of this md5-object. Internally, a copy is made
and the \C-function \code{MD5Final} is called. Finally the digest is
returned.
\end{funcdesc}
\begin{funcdesc}{copy}{}
Return a separate copy of this md5-object. An \code{update} to this
copy won't affect the original object.
\end{funcdesc}