Working on a project site with user creation/login this morning. The code was working fine on localhost. I pushed the code to my heroku account and left for the day. This evening I returned home and began testing the site. I was getting an exception I was not prepared for. Started up localhost and recreated the issue which is TypeError: '_PasslibRegistryProxy' object is not callable
and now I have no clue how to resolve it. It would appear that in the process of git adding, committing and pushing, I broke my passlib files. Yet, I have done no editing of the source code for passlib. In addition, I recreated the error with minimal code in an entirely new workspace. New harddrive entirely, new folder, ran pip install passlib -t .
(forces installation into that directory). I ran the following 3 lines of code and continued to receive the same error:
import passlib.hash
a = passlib.hash('magic15!')
print(a)
In my primary workspace, I attempted pip install passlib --upgrade -t .
and that didn't resolve my issue. And I'm using passlib.hash()
rather than the sha256_encrypt()
due to the deprecated message.
I'm completely befuddled because this was working fine and I've done no changes to that code other than attempting to resolve it.
If I get to this in 2024, chances it's still relevant. So, as of Passlib 1.7.4
This will show a DeprecationWarning:
python3 -c "from passlib.hash import sha512_crypt; import getpass; print(sha512_crypt.encrypt('password'))"
New and Recommended approach for Passlib 1.7 (No warning)
python3 -c "from passlib.hash import sha512_crypt; import getpass; print(sha512_crypt.hash('password'))"
Or
from passlib.hash import sha512_crypt
# Example password
password = "my_secure_password"
# Hash the password using sha512_crypt
hashed_password = sha512_crypt.hash(password)
print("Hashed password:", hashed_password)