wushuyi / passlib

Automatically exported from code.google.com/p/passlib
Other
0 stars 0 forks source link

brcypt support broken for 2.0.0 #56

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
$ pip install bcrypt==2.0.0 passlib==1.6.2
$ python
>>> from passlib.hash import bcrypt
>>> bcrypt.encrypt('foo')

What is the expected output? What do you see instead?
Expected: hash value
Actual (Python 2 or bcrypt<2.0.0): hash value
Actual (Python 3.4.3, bcrypt==2.0.0):
  ...
  File "/Users/jonafato/.virtualenvs/scratch/lib/python3.4/site-packages/passlib/handlers/bcrypt.py", line 333, in _calc_checksum_pybcrypt
    hash = _bcrypt.hashpw(secret, config)
  File "/Users/jonafato/.virtualenvs/scratch/lib/python3.4/site-packages/bcrypt/__init__.py", line 57, in hashpw
    raise TypeError("Unicode-objects must be encoded before hashing")

What version of the passlib & python are you using? On what operating
system?
passlib==1.6.2, python 3.x, Mac OS X 10.10.3

Please provide any additional information below.
This is happening because of a change in bcrypt. passlib differentiates bcrypt 
from py-bcrypt using `if not hasattr(_bcrypt, "_ffi"):`. bcrypt 2.0.0 has 
several code organizational changes, one of which affects this check. Changing 
the line to `if not (hasattr(_bcrypt, "_ffi") or hasattr(_bcrypt, "_bcrypt")):` 
should handle both versions gracefully.

Original issue reported on code.google.com by Jonathan...@gmail.com on 23 Jun 2015 at 7:01