Ticket #9101: django-salts.diff

File django-salts.diff, 859 bytes (added by Ludvig Ericson, 16 years ago)
  • django/contrib/auth/models.py

     
    77from django.utils.translation import ugettext_lazy as _
    88import datetime
    99import urllib
     10import random
     11import string
    1012
    1113UNUSABLE_PASSWORD = '!' # This will never be a valid hash
     14SALT_CHARS = string.letters + string.digits
    1215
    1316try:
    1417    set
     
    173176        return full_name.strip()
    174177
    175178    def set_password(self, raw_password):
    176         import random
    177179        algo = 'sha1'
    178         salt = get_hexdigest(algo, str(random.random()), str(random.random()))[:5]
     180        salt = ''.join(random.sample(SALT_CHARS, 5))
    179181        hsh = get_hexdigest(algo, salt, raw_password)
    180182        self.password = '%s$%s$%s' % (algo, salt, hsh)
    181183
Back to Top