Ticket #9101: 9101.diff

File 9101.diff, 1014 bytes (added by Matt Boersma, 15 years ago)

Updated patch to use string.punctuation as well

  • django/contrib/auth/models.py

     
    11import datetime
     2import string
    23import urllib
    34
    45from django.contrib import auth
     
    1011from django.utils.hashcompat import md5_constructor, sha_constructor
    1112from django.utils.translation import ugettext_lazy as _
    1213
     14SALT_CHARS = string.letters + string.digits + string.punctuation
    1315UNUSABLE_PASSWORD = '!' # This will never be a valid hash
    1416
    1517try:
     
    164166        return full_name.strip()
    165167
    166168    def set_password(self, raw_password):
    167         import random
     169        from random import sample
    168170        algo = 'sha1'
    169         salt = get_hexdigest(algo, str(random.random()), str(random.random()))[:5]
     171        salt = ''.join(sample(SALT_CHARS, 5))
    170172        hsh = get_hexdigest(algo, salt, raw_password)
    171173        self.password = '%s$%s$%s' % (algo, salt, hsh)
    172174
Back to Top