47. Authentication and Password Handling Basics
Secure authentication requires strong password policies and safe verification.
Example
import bcrypt
password = b"secret123"
hashed = bcrypt.hashpw(password, bcrypt.gensalt())
print("Stored hash:", hashed)
# 47. Verification
if bcrypt.checkpw(password, hashed):
print("Access granted")
else:
print("Access denied")
✅ Lesson: Always store password hashes, not plaintext. Use bcrypt or similar secure libraries.