Ticket #6028: md5-crypt-as-algo-name.diff
File md5-crypt-as-algo-name.diff, 1.2 KB (added by , 17 years ago) |
---|
-
django/contrib/auth/models.py
19 19 def get_hexdigest(algorithm, salt, raw_password): 20 20 """ 21 21 Returns a string of the hexdigest of the given plaintext password and salt 22 using the given algorithm ('md5', 'sha1' or 'crypt').22 using the given algorithm ('md5', 'sha1', 'crypt' or 'md5-crypt'). 23 23 """ 24 24 raw_password, salt = smart_str(raw_password), smart_str(salt) 25 if algorithm == 'crypt':25 if algorithm in ('crypt', 'md5-crypt'): 26 26 try: 27 27 import crypt 28 28 except ImportError: … … 51 51 Returns a boolean of whether the raw_password was correct. Handles 52 52 encryption formats behind the scenes. 53 53 """ 54 algo, salt, hsh = enc_password.split('$') 54 algo, salt_and_hash = enc_password.split('$', 1) 55 if algo == 'md5-crypt': 56 salt = hsh = salt_and_hash 57 else: 58 salt, hsh = salt_and_hash.rsplit('$', 1) 55 59 return hsh == get_hexdigest(algo, salt, raw_password) 56 60 57 61 class SiteProfileNotAvailable(Exception):