Bird
0
0

In a Flask application, which of the following code snippets correctly generates a hashed password using Werkzeug's security utilities?

easy📝 Syntax Q3 of 15
Flask - Security Best Practices
In a Flask application, which of the following code snippets correctly generates a hashed password using Werkzeug's security utilities?
Ahashed_password = hash_password('user_password')
Bhashed_password = generate_password_hash('user_password')
Chashed_password = werkzeug.hash('user_password')
Dhashed_password = generate_hash('user_password')
Step-by-Step Solution
Solution:
  1. Step 1: Identify the correct function

    The Werkzeug security module provides generate_password_hash to hash passwords securely.
  2. Step 2: Check the syntax

    The correct usage is generate_password_hash('password'), which returns a hashed string.
  3. Final Answer:

    hashed_password = generate_password_hash('user_password') -> Option B
  4. Quick Check:

    Function name and usage match official Werkzeug docs [OK]
Quick Trick: Use generate_password_hash() to hash passwords securely [OK]
Common Mistakes:
MISTAKES
  • Using non-existent functions like hash_password()
  • Confusing generate_password_hash with generate_hash
  • Calling hashing functions without importing Werkzeug

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes