Ticket #9101: django-salts.diff
File django-salts.diff, 859 bytes (added by , 16 years ago) |
---|
-
django/contrib/auth/models.py
7 7 from django.utils.translation import ugettext_lazy as _ 8 8 import datetime 9 9 import urllib 10 import random 11 import string 10 12 11 13 UNUSABLE_PASSWORD = '!' # This will never be a valid hash 14 SALT_CHARS = string.letters + string.digits 12 15 13 16 try: 14 17 set … … 173 176 return full_name.strip() 174 177 175 178 def set_password(self, raw_password): 176 import random177 179 algo = 'sha1' 178 salt = get_hexdigest(algo, str(random.random()), str(random.random()))[:5]180 salt = ''.join(random.sample(SALT_CHARS, 5)) 179 181 hsh = get_hexdigest(algo, salt, raw_password) 180 182 self.password = '%s$%s$%s' % (algo, salt, hsh) 181 183