diff --git a/_practices/safe-password-storage/_python/generate_data.py b/_practices/safe-password-storage/_python/generate_data.py index 1366831..f011f7c 100644 --- a/_practices/safe-password-storage/_python/generate_data.py +++ b/_practices/safe-password-storage/_python/generate_data.py @@ -31,7 +31,8 @@ def __init__(self, salt=None, pepper=None, rounds=None): def encode(self, password): if self.salt is None: - return hashlib.md5(password).hexdigest() + # Added encode() to handle TypeError: Unicode-objects must be encoded before hashing + return hashlib.md5(password.encode()).hexdigest() elif self.salt == 'same': salt = self.global_salt elif self.salt == 'user': @@ -67,7 +68,8 @@ def __init__(self, salt=None, pepper=None, rounds=None): raise NotImplementedError("BCRYPT NEEDS A SALT MORON") self.salt = salt - self.pepper = pepper + # Added encode() to handle TypeError: can only concatenate str (not "bytes") to str + self.pepper = pepper.encode() def encode(self, password): if self.salt == 'same':