Commits

Kelvin Wong committed 3d5f566 Draft

Rename linefeed cleaner function

Comments (0)

Files changed (2)

django_scrypt/hashers.py

             return str(s).strip()
 
 
-def clean_base64_scrypt_hash(hash):
+def remove_linefeeds_from_base64_hash(hash):
     """Cleans the Base64 fragment of linefeeds"""
     algorithm, salt, Nexp, r, p, buflen, h = hash.split('$')
     h = enbase64(debase64(h))
 
         """
         assert encoded
-        encoded = clean_base64_scrypt_hash(encoded)
+        encoded = remove_linefeeds_from_base64_hash(encoded)
         algorithm, salt, Nexp, r, p, buflen, h = encoded.split('$')
         assert algorithm == self.algorithm
         # TODO: buflen is an experimental proposal in py-scrypt

tests/test_django_scrypt.py

 import django_scrypt
 from django_scrypt.hashers import (
     ScryptPasswordHasher, enbase64, debase64, stringify,
-    clean_base64_scrypt_hash)
+    remove_linefeeds_from_base64_hash)
 
 try:
     import scrypt
         # Unicode string is encoded to UTF-8
         self.assertTrue(isinstance(stringify(self.unicode_str), str))
 
-    def test_clean_base64_scrypt_hash(self):
+    def test_remove_linefeeds_from_base64_hash(self):
         """Hashes are cleaned of linefeeds"""
         hash_lf = (
             'scrypt$h64FF0EdQ1f9$14$8$1$64$refoMN0aZci6vt0VOPKB7tfgPS/wgAWXxz'
             'scrypt$h64FF0EdQ1f9$14$8$1$64$refoMN0aZci6vt0VOPKB7tfgPS/wgAWXxz'
             'e1z8CSzTzVSUV0hT3ByyE3YKPCpOegxJfZ6CZgQ+DShd3G65p24Q==')
         unicode_pwd = 'a\xac\u1234\u20ac\u8000'
-        h = clean_base64_scrypt_hash(hash_lf)
+        h = remove_linefeeds_from_base64_hash(hash_lf)
         self.assertTrue(check_password(unicode_pwd, h))
-        h = clean_base64_scrypt_hash(hash)
+        h = remove_linefeeds_from_base64_hash(hash)
         self.assertTrue(check_password(unicode_pwd, h))