The Pre Hash Nobody Keyed
A team knows bcrypt has a 72-byte input limit and writes this to get around it.
import bcrypt, hashlib
def store(password: str) -> bytes:
# "bcrypt truncates long passwords, so hash first"
digest = hashlib.sha256(password.encode()).digest() # 32 raw bytes
return bcrypt.hashpw(digest, bcrypt.gensalt(12))
The binding accepts the raw digest without complaint and every test passes. What is the defect?
Sign in to answer questions and track your progress
Sign In