Performance: Password hashing with bcrypt
MEDIUM IMPACT
This affects server response time and user experience during authentication by adding CPU work for hashing passwords securely.
import bcrypt password = b"user_password" hashed = bcrypt.hashpw(password, bcrypt.gensalt(rounds=12))
import bcrypt password = b"user_password" hashed = bcrypt.hashpw(password, bcrypt.gensalt(rounds=4))
| Pattern | CPU Load | Blocking | Security Strength | Verdict |
|---|---|---|---|---|
| Low cost factor (rounds=4) | Low CPU | Minimal blocking | Weak security | [X] Bad |
| Recommended cost factor (rounds=12) | Medium CPU | Moderate blocking | Strong security | [OK] Good |
| Synchronous verification | Medium CPU | Blocks event loop | Strong security | [X] Bad |
| Asynchronous verification | Medium CPU | Non-blocking | Strong security | [OK] Good |