Bird
0
0

What will be the output of this code snippet?

medium📝 Predict Output Q4 of 15
FastAPI - Authentication and Security
What will be the output of this code snippet? ```python from passlib.context import CryptContext pwd_context = CryptContext(schemes=["bcrypt"]) hashed = pwd_context.hash("mypassword") print(pwd_context.verify("mypassword", hashed)) ```
ATrue
BFalse
CError: hash method missing argument
DError: verify method missing argument
Step-by-Step Solution
Solution:
  1. Step 1: Understand hash and verify usage

    Hash creates a bcrypt hash of "mypassword". Verify checks if the plain password matches the hash.
  2. Step 2: Predict output of verify

    Since the password matches the hash, verify returns True.
  3. Final Answer:

    True -> Option A
  4. Quick Check:

    Verify correct password = True [OK]
Quick Trick: Verify returns True if password matches hash [OK]
Common Mistakes:
MISTAKES
  • Thinking hash or verify require extra arguments
  • Expecting verify to return False for correct password

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FastAPI Quizzes