Incompatibility with bcrypt backend
Created originally on Bitbucket by Anonymous
(Imported from Google Code)
leckey.ryan wrote:
What steps will reproduce the problem?
1. pip install passlib
2. pip install bcrypt
3. passlib.hash.bcrypt.encrypt('password')
What is the expected output? What do you see instead?
The expected output is the hashed password. Instead the
traceback below occurs.
What version of the product are you using? On what operating system?
I've tried this both with the latest release (1.6.1) and with the default branch from source control.
Please provide any additional information below.
Below is the traceback.
.../python3.3/site-packages/passlib/utils/handlers.py in encrypt(cls, secret, **kwds)
551 validate_secret(secret)
552 self = cls(use_defaults=True, **kwds)
--> 553 self.checksum = self._calc_checksum(secret)
554 return self.to_string()
555
.../python3.3/site-packages/passlib/handlers/bcrypt.py in _calc_checksum_pybcrypt_threadsafe(self, secret)
277 # used through passlib, this should be safe.
278 with self._calc_lock:
--> 279 return self._calc_checksum_pybcrypt(secret)
280
281 def _calc_checksum_pybcrypt(self, secret):
.../python3.3/site-packages/passlib/handlers/bcrypt.py in _calc_checksum_pybcrypt(self, secret)
289 raise uh.exc.NullPasswordError(self)
290 config = self._get_config()
--> 291 hash = _pybcrypt_hashpw(secret, config)
292 assert hash.startswith(config) and len(hash) == len(config)+31
293 return str_to_uascii(hash[-31:])
.../python3.3/site-packages/bcrypt/__init__.py in hashpw(password, salt)
89 def hashpw(password, salt):
90 if isinstance(password, text_type) or isinstance(salt, text_type):
---> 91 raise TypeError("Unicode-objects must be encoded before hashing")
92
93 hashed = _ffi.new("unsigned char[]", 128)
TypeError: Unicode-objects must be encoded before hashing
If you need anything else; let me know.