Ticket #26395: crypt_return_none.diff

File crypt_return_none.diff, 1.1 KB (added by L. Coues, 9 years ago)

patch

  • django/contrib/auth/hashers.py

    diff --git a/django/contrib/auth/hashers.py b/django/contrib/auth/hashers.py
    index 7658379..57b8809 100644
    a b class CryptPasswordHasher(BasePasswordHasher):  
    602602        crypt = self._load_library()
    603603        assert len(salt) == 2
    604604        data = crypt.crypt(force_str(password), salt)
     605        assert data != None
    605606        # we don't need to store the salt, but Django used to do this
    606607        return "%s$%s$%s" % (self.algorithm, '', data)
    607608
  • tests/auth_tests/test_hashers.py

    diff --git a/tests/auth_tests/test_hashers.py b/tests/auth_tests/test_hashers.py
    index a43c170..d5708b0 100644
    a b try:  
    2020except ImportError:
    2121    crypt = None
    2222
     23# On some platform, crypt can be imported but crypt.crypt always return None
     24if crypt and crypt.crypt("") == None:
     25    crypt = None
     26
    2327try:
    2428    import bcrypt
    2529except ImportError:
    try:  
    3034except ImportError:
    3135    argon2 = None
    3236
    33 
    3437class PBKDF2SingleIterationHasher(PBKDF2PasswordHasher):
    3538    iterations = 1
    3639
Back to Top