diff --git a/django/contrib/auth/hashers.py b/django/contrib/auth/hashers.py
index 5824685..8b28d52 100644
a
|
b
|
PREFERRED_HASHER = None # defaults to first item in PASSWORD_HASHERS
|
16 | 16 | |
17 | 17 | |
18 | 18 | def is_password_usable(encoded): |
19 | | return (encoded is not None and encoded != UNUSABLE_PASSWORD) |
| 19 | return (encoded is not None and encoded != UNUSABLE_PASSWORD and ('$' in encoded or len(encoded) == 32)) |
20 | 20 | |
21 | 21 | |
22 | 22 | def check_password(password, encoded, setter=None, preferred='default'): |
… |
… |
def check_password(password, encoded, setter=None, preferred='default'):
|
35 | 35 | password = smart_str(password) |
36 | 36 | encoded = smart_str(encoded) |
37 | 37 | |
38 | | if len(encoded) == 32 and '$' not in encoded: |
| 38 | if '$' not in encoded: |
39 | 39 | hasher = get_hasher('unsalted_md5') |
40 | 40 | else: |
41 | 41 | algorithm = encoded.split('$', 1)[0] |
diff --git a/django/contrib/auth/tests/hashers.py b/django/contrib/auth/tests/hashers.py
index 8a11511..2520d42 100644
a
|
b
|
class TestUtilsHashPass(unittest.TestCase):
|
90 | 90 | make_password('letmein', hasher='lolcat') |
91 | 91 | self.assertRaises(ValueError, doit) |
92 | 92 | |
| 93 | def test_bad_encoded_pasword(self): |
| 94 | encoded = 'letmeinbadencoded' |
| 95 | self.assertFalse(is_password_usable(encoded)) |
| 96 | |
| 97 | |
93 | 98 | def test_low_level_pkbdf2(self): |
94 | 99 | hasher = PBKDF2PasswordHasher() |
95 | 100 | encoded = hasher.encode('letmein', 'seasalt') |