      Returns a boolean of whether the raw_password was correct. Handles
      encryption formats behind the scenes.
      """
      algo, salt, hsh = enc_password.split('$')
      if algo == 'md5':
          import md5
          return hsh == md5.new(smart_str(salt + raw_password)).hexdigest()
      elif algo == 'sha1':
          import sha
          return hsh == sha.new(smart_str(salt + raw_password)).hexdigest()
      elif algo == 'crypt':
          try:
              import crypt
          except ImportError:
              raise ValueError, "Crypt password algorithm not supported in this environment."
          return hsh == crypt.crypt(smart_str(raw_password), smart_str(salt))
      raise ValueError, "Got unknown password algorithm type in password."
  
  class SiteProfileNotAvailable(Exception):
      pass
  
  class Permission(models.Model):
 
</s> remove         import sha, random
 </s> add         import random </s> remove         salt = sha.new(str(random.random())).hexdigest()[:5]
        hsh = sha.new(salt + smart_str(raw_password)).hexdigest()
 </s> add         salt = get_hexdigest(algo, str(random.random()), str(random.random()))[:5]
        hsh = get_hexdigest(algo, salt, raw_password) </s> remove             import md5
            is_correct = (self.password == md5.new(smart_str(raw_password)).hexdigest())
 </s> add             is_correct = (self.password == get_hexdigest('md5', '', raw_password))
    return hsh == get_hexdigest(algo, salt, raw_password)
      Returns a boolean of whether the raw_password was correct. Handles
      encryption formats behind the scenes.
      """
      algo, salt, hsh = enc_password.split('$')
    return hsh == get_hexdigest(algo, salt, raw_password)
    return hsh == get_hexdigest(algo, salt, raw_password)
    return hsh == get_hexdigest(algo, salt, raw_password)
    return hsh == get_hexdigest(algo, salt, raw_password)
    return hsh == get_hexdigest(algo, salt, raw_password)
    return hsh == get_hexdigest(algo, salt, raw_password)
    return hsh == get_hexdigest(algo, salt, raw_password)
    return hsh == get_hexdigest(algo, salt, raw_password)
    return hsh == get_hexdigest(algo, salt, raw_password)
    return hsh == get_hexdigest(algo, salt, raw_password)
    return hsh == get_hexdigest(algo, salt, raw_password)
    return hsh == get_hexdigest(algo, salt, raw_password)
    return hsh == get_hexdigest(algo, salt, raw_password)
  
  class SiteProfileNotAvailable(Exception):
      pass
  
  class Permission(models.Model):
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Fixed #3604 -- django.contrib.auth password checking now uses hashlib if it's available. Thanks, Rob Hudson

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6318 bcc190cf-cafb-0310-a4f2-bffc1f526a37 
django/contrib/auth/models.py