Ticket #9101: 9101.diff
File 9101.diff, 1014 bytes (added by , 16 years ago) |
---|
-
django/contrib/auth/models.py
1 1 import datetime 2 import string 2 3 import urllib 3 4 4 5 from django.contrib import auth … … 10 11 from django.utils.hashcompat import md5_constructor, sha_constructor 11 12 from django.utils.translation import ugettext_lazy as _ 12 13 14 SALT_CHARS = string.letters + string.digits + string.punctuation 13 15 UNUSABLE_PASSWORD = '!' # This will never be a valid hash 14 16 15 17 try: … … 164 166 return full_name.strip() 165 167 166 168 def set_password(self, raw_password): 167 import random169 from random import sample 168 170 algo = 'sha1' 169 salt = get_hexdigest(algo, str(random.random()), str(random.random()))[:5]171 salt = ''.join(sample(SALT_CHARS, 5)) 170 172 hsh = get_hexdigest(algo, salt, raw_password) 171 173 self.password = '%s$%s$%s' % (algo, salt, hsh) 172 174