[Python-checkins] CVS: python/dist/src/Doc/lib libcrypt.tex,1.14,1.14.4.1
Fred L. Drake
fdrake@weyr.cnri.reston.va.us
Mon, 14 Feb 2000 17:17:11 -0500 (EST)
Update of /projects/cvsroot/python/dist/src/Doc/lib
In directory weyr:/home/fdrake/projects/python/Doc-152p1/lib
Modified Files:
Tag: release152p1-patches
libcrypt.tex
Log Message:
Revisions and example from Peter Funk <pf@artcom-gmbh.de>.
Index: libcrypt.tex
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Doc/lib/libcrypt.tex,v
retrieving revision 1.14
retrieving revision 1.14.4.1
diff -C2 -r1.14 -r1.14.4.1
*** libcrypt.tex 1999/03/02 17:03:35 1.14
--- libcrypt.tex 2000/02/14 22:17:08 1.14.4.1
***************
*** 1,28 ****
\section{\module{crypt} ---
! Function used to check \UNIX{} passwords}
\declaremodule{builtin}{crypt}
\platform{Unix}
! \modulesynopsis{The \cfunction{crypt()} function used to check \UNIX{}
! passwords.}
\moduleauthor{Steven D. Majewski}{sdm7g@virginia.edu}
\sectionauthor{Steven D. Majewski}{sdm7g@virginia.edu}
! This module implements an interface to the \manpage{crypt}{3} routine,
! which is a one-way hash function based upon a modified DES algorithm;
! see the \UNIX{} man page for further details. Possible uses include
allowing Python scripts to accept typed passwords from the user, or
attempting to crack \UNIX{} passwords with a dictionary.
- \index{crypt(3)}
\begin{funcdesc}{crypt}{word, salt}
! \var{word} will usually be a user's password. \var{salt} is a
! 2-character string which will be used to select one of 4096 variations
! of DES\indexii{cipher}{DES}. The characters in \var{salt} must be
! either \character{.}, \character{/}, or an alphanumeric character.
! Returns the hashed password as a string, which will be composed of
! characters from the same alphabet as the salt.
\end{funcdesc}
The module and documentation were written by Steve Majewski.
--- 1,44 ----
\section{\module{crypt} ---
! Function to check \UNIX{} passwords}
\declaremodule{builtin}{crypt}
\platform{Unix}
! \modulesynopsis{The \cfunction{crypt()} function used to check
! \UNIX{} passwords.}
\moduleauthor{Steven D. Majewski}{sdm7g@virginia.edu}
\sectionauthor{Steven D. Majewski}{sdm7g@virginia.edu}
! This module implements an interface to the
! \manpage{crypt}{3}\index{crypt(3)} routine, which is a one-way hash
! function based upon a modified DES\indexii{cipher}{DES} algorithm; see
! the \UNIX{} man page for further details. Possible uses include
allowing Python scripts to accept typed passwords from the user, or
attempting to crack \UNIX{} passwords with a dictionary.
\begin{funcdesc}{crypt}{word, salt}
! \var{word} will usually be a user's password as typed at a prompt or
! in a graphical interface. \var{salt} is usually a random
! two-character string which will be used to perturb the DES algorithm
! in one of 4096 ways. The characters in \var{salt} must be in the set
! \regexp{[./a-zA-Z0-9]}. Returns the hashed password as a string,
! which will be composed of characters from the same alphabet as the
! salt (the first two characters represent the salt itself).
\end{funcdesc}
+
+
+ A simple example illustrating typical use:
+
+ \begin{verbatim}
+ import crypt, getpass, pwd
+ def login():
+ username = raw_input('Python login:')
+ cryptedpasswd = pwd.getpwnam(username)[1]
+ if cryptedpasswd:
+ if cryptedpasswd == 'x' or cryptedpasswd == '*':
+ raise "Sorry, currently no support for shadow passwords"
+ cleartext = getpass.getpass()
+ return crypt(cleartext, cryptedpasswd[0:2]) == cryptedpasswd
+ \end{verbatim}
The module and documentation were written by Steve Majewski.