Skip to content

Commit

Permalink
Only return the string length that Drupal has stored
Browse files Browse the repository at this point in the history
  • Loading branch information
halstead committed Aug 10, 2012
1 parent 1b9838b commit 5306f17
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drupalpass/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ def custom64(self, string, count = 0):
return output

def rehash(self, stored_hash, password):
hash_length = len(stored_hash)
# Plain Drupal 6 compatibility
if len(stored_hash) == 32 and stored_hash.find('$') == -1:
if hash_length == 32 and stored_hash.find('$') == -1:
return hashlib.md5(password).hexdigest()
# Drupal 7 and phpass compatible passwords
if stored_hash[0:2] == 'U$':
Expand All @@ -86,7 +87,9 @@ def rehash(self, stored_hash, password):
else:
# We don't know how to deal with this hash type
return False
return hash_prefix + hash_str
hash_str = hash_prefix + hash_str
# Only return the length that Drupal has stored
return hash_str[:hash_length]

if __name__ == "__main__":
ha = '$S$D5z1Wm4bevjS5EQ3OdB.lI0NFTnCyIuD6VFHs5fkdjFHo0lvsdmv'
Expand Down

0 comments on commit 5306f17

Please sign in to comment.