Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…o support

easy porting from existing Unix-based legacy apps. Thanks, axiak@mit.edu.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5073 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2a7d9ef23fff757d5aa8052c165cc189819e5ee2 1 parent 5dfe74f
Malcolm Tredinnick authored April 25, 2007
1  AUTHORS
@@ -49,6 +49,7 @@ answer newbie questions, and generally made Django that much better:
49 49
     ant9000@netwise.it
50 50
     David Ascher <http://ascher.ca/>
51 51
     Arthur <avandorp@gmail.com>
  52
+    axiak@mit.edu
52 53
     Jiri Barton
53 54
     Ned Batchelder <http://www.nedbatchelder.com/>
54 55
     Shannon -jj Behrens <http://jjinux.blogspot.com/>
6  django/contrib/auth/models.py
@@ -17,6 +17,12 @@ def check_password(raw_password, enc_password):
17 17
     elif algo == 'sha1':
18 18
         import sha
19 19
         return hsh == sha.new(salt+raw_password).hexdigest()
  20
+    elif algo == 'crypt':
  21
+        try:
  22
+            import crypt
  23
+        except ImportError:
  24
+            raise ValueError, "Crypt password algorithm not supported in this environment."
  25
+        return hsh == crypt.crypt(raw_password, salt)
20 26
     raise ValueError, "Got unknown password algorithm type in password."
21 27
 
22 28
 class SiteProfileNotAvailable(Exception):
8  docs/authentication.txt
@@ -204,9 +204,11 @@ The ``password`` attribute of a ``User`` object is a string in this format::
204 204
 
205 205
 That's hashtype, salt and hash, separated by the dollar-sign character.
206 206
 
207  
-Hashtype is either ``sha1`` (default) or ``md5`` -- the algorithm used to
208  
-perform a one-way hash of the password. Salt is a random string used to salt
209  
-the raw password to create the hash.
  207
+Hashtype is either ``sha1`` (default), ``md5`` or ``crypt`` -- the algorithm
  208
+used to perform a one-way hash of the password. Salt is a random string used
  209
+to salt the raw password to create the hash. Note that the ``crypt`` method is
  210
+only supported on platforms that have the standard Python ``crypt`` module
  211
+available.
210 212
 
211 213
 For example::
212 214
 

0 notes on commit 2a7d9ef

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