Search code examples
pythonbcryptblowfish

2y-blowfish hash keys in Python for shadow


As I found out, 2a shadow hash keys are deprecated because 2a has implementation flaws. It's been corrected in 2011 and now 2y-hashes are used widely on Linux systems.

I tried to find a Python library which calculates 2y-hashes, but I failed. I searched at least two hours and had a look at all libraries available but every single library for Python only calculates 2a hashes. The most of them are wrapper for the reference bcrypt from BSD but they only calculate 2a-hashes.


Solution

  • The passlib.hash.bcrypt class from the passlib password hashing library supports the 2y format. Note that you should also install py-bcrypt as a dependency.