bcrypt_sha256 does not support 2b or 2y ident values
Created originally on Bitbucket by Anonymous
bcrypt_sha256 does not allow 2b or 2y values for the ident keyword (the ident keyword is present as shown by setting to '2a')
Python 3.5.2 passlib==1.6.5 bcrypt==3.1.0
#!python
from passlib.hash import bcrypt
from passlib.hash import bcrypt_sha256
def main():
print("using plain bcrypt for comparison")
print("\nexplicitly set 2b ident:")
hash_bcrypt2b = bcrypt.encrypt("password", ident='2b')
print(hash_bcrypt2b)
>>$2b$12$qgAUZ7R15aF/gYBFDPG89uwSUCoQECDV1e6TSRoVU3OfUVCAxJ/aq
print("\nnow using bcrypt_sha256\n")
print ("using default bcrypt_sha256: expect 2a variant, 12 rounds")
hash_default_bcrypt_256 = bcrypt_sha256.encrypt("password")
print(hash_default_bcrypt_256)
>>$bcrypt-ha256$2a,12$lPWbt4v/UrEFmLFJCFhJ8O$Yw70OOxq.NGIqSClLbpjGtYYyhRPxeu
print("\nexplicitly set 2a ident")
hash_bcrypt2a_256 = bcrypt_sha256.encrypt("password", ident='2a')
print(hash_bcrypt2a_256)
>>$bcrypt-sha256$2a,12$jqLk7tepYQAv0tAjejtt.O$P7Pts3z0JZvB013NpAnxBTX4z7iS.6.
print("\nexplicitly set 2b ident:")
hash_bcrypt2b_256 = bcrypt_sha256.encrypt("password", ident='2b')
print(hash_bcrypt2b_256)
Traceback (most recent call last):
File "C:\Users\Charlie\Documents\popup_sales\python\passlib_ident_bug.py", line 41, in <module>
main()
File "C:\Users\Charlie\Documents\popup_sales\python\passlib_ident_bug.py", line 33, in main
hash_bcrypt2b_256 = bcrypt_sha256.encrypt("password", ident='2b')
File "C:\python\lib\site-packages\passlib\utils\handlers.py", line 557, in encrypt
self = cls(use_defaults=True, **kwds)
File "C:\python\lib\site-packages\passlib\utils\handlers.py", line 849, in __init__
self.ident = self._norm_ident(ident)
File "C:\python\lib\site-packages\passlib\utils\handlers.py", line 880, in _norm_ident
raise ValueError("invalid ident: %r" % (ident,))
>>**ValueError: invalid ident: '2b'*