Bird
0
0

You want to securely store user passwords in your Flask app and verify them on login. Which approach follows best practices?

hard📝 Application Q15 of 15
Flask - Security Best Practices
You want to securely store user passwords in your Flask app and verify them on login. Which approach follows best practices?
AStore plain passwords in the database and compare them directly on login.
BEncrypt passwords with a reversible method and decrypt them on login to compare.
CHash passwords with generate_password_hash before storing, then verify with check_password_hash during login.
DStore passwords as plain text but log them only during login attempts.
Step-by-Step Solution
Solution:
  1. Step 1: Understand secure password storage

    Passwords must be hashed before storing to prevent exposure if database leaks.
  2. Step 2: Verify passwords securely on login

    Use check_password_hash to compare the stored hash with the login password safely.
  3. Final Answer:

    Hash passwords with generate_password_hash before storing, then verify with check_password_hash during login. -> Option C
  4. Quick Check:

    Hash before store, verify with check_password_hash [OK]
Quick Trick: Hash before store, verify with check_password_hash on login [OK]
Common Mistakes:
MISTAKES
  • Storing or logging plain passwords
  • Using reversible encryption instead of hashing
  • Comparing plain passwords directly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes