Ticket #5600: salt.diff
File salt.diff, 819 bytes (added by , 17 years ago) |
---|
-
contrib/auth/models.py
8 8 from django.utils.translation import ugettext_lazy as _ 9 9 import datetime 10 10 import urllib 11 import string 11 12 12 13 UNUSABLE_PASSWORD = '!' # This will never be a valid hash 14 SALT_CHARACTERS = string.ascii_letters + string.digits 13 15 14 16 try: 15 17 set … … 183 185 def set_password(self, raw_password): 184 186 import random 185 187 algo = 'sha1' 186 salt = get_hexdigest(algo, str(random.random()), str(random.random()))[:5]188 salt = ''.join(random.choice(SALT_CHARACTERS) for c in range(10)) 187 189 hsh = get_hexdigest(algo, salt, raw_password) 188 190 self.password = '%s$%s$%s' % (algo, salt, hsh) 189 191