import bcrypt def hash_password(password: str): """Hash a password using bcrypt""" password_bytes = password.encode('utf-8') salt = bcrypt.gensalt() return bcrypt.hashpw(password_bytes, salt).decode('utf-8') def verify_password(plain_password: str, hashed_password: str): """Verify a plain password against the hashed password""" password_bytes = plain_password.encode('utf-8') hashed_bytes = hashed_password.encode('utf-8') return bcrypt.checkpw(password_bytes, hashed_bytes)