Bird
0
0

What will the following Flask code output if the password check fails?

medium📝 Predict Output Q4 of 15
Flask - Security Best Practices
What will the following Flask code output if the password check fails?
from werkzeug.security import check_password_hash, generate_password_hash
stored_hash = generate_password_hash('secret123')
result = check_password_hash(stored_hash, 'wrongpass')
print(result)
AFalse
BError
CNone
DTrue
Step-by-Step Solution
Solution:
  1. Step 1: Understand check_password_hash behavior

    This function returns True if the password matches the hash, otherwise False.
  2. Step 2: Analyze the given password check

    The stored hash is for 'secret123', but the check is for 'wrongpass', so it returns False.
  3. Final Answer:

    False -> Option A
  4. Quick Check:

    Password mismatch check = False [OK]
Quick Trick: check_password_hash returns False on wrong password [OK]
Common Mistakes:
MISTAKES
  • Expecting True on wrong password
  • Assuming None or error is returned
  • Confusing hash generation with checking

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes