Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fixed #3316 -- Added support for crypt hashing of passwords, mostly t…

…o support

easy porting from existing Unix-based legacy apps. Thanks,

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2a7d9ef23fff757d5aa8052c165cc189819e5ee2 1 parent 5dfe74f
@malcolmt malcolmt authored
1  AUTHORS
@@ -49,6 +49,7 @@ answer newbie questions, and generally made Django that much better:
David Ascher <>
Arthur <>
Jiri Barton
Ned Batchelder <>
Shannon -jj Behrens <>
6 django/contrib/auth/
@@ -17,6 +17,12 @@ def check_password(raw_password, enc_password):
elif algo == 'sha1':
import sha
return hsh ==
+ elif algo == 'crypt':
+ try:
+ import crypt
+ except ImportError:
+ raise ValueError, "Crypt password algorithm not supported in this environment."
+ return hsh == crypt.crypt(raw_password, salt)
raise ValueError, "Got unknown password algorithm type in password."
class SiteProfileNotAvailable(Exception):
8 docs/authentication.txt
@@ -204,9 +204,11 @@ The ``password`` attribute of a ``User`` object is a string in this format::
That's hashtype, salt and hash, separated by the dollar-sign character.
-Hashtype is either ``sha1`` (default) or ``md5`` -- the algorithm used to
-perform a one-way hash of the password. Salt is a random string used to salt
-the raw password to create the hash.
+Hashtype is either ``sha1`` (default), ``md5`` or ``crypt`` -- the algorithm
+used to perform a one-way hash of the password. Salt is a random string used
+to salt the raw password to create the hash. Note that the ``crypt`` method is
+only supported on platforms that have the standard Python ``crypt`` module
For example::

0 comments on commit 2a7d9ef

Please sign in to comment.
Something went wrong with that request. Please try again.