Bird
0
0

This Flask code snippet throws an error:

medium📝 Debug Q7 of 15
Flask - Security Best Practices
This Flask code snippet throws an error:
from werkzeug.security import generate_password_hash
hashed = generate_password_hash(123456)

What is the cause?
AWerkzeug is not imported correctly
Bgenerate_password_hash requires two arguments
CHashing integers is not supported by any library
DPassword must be a string, not an integer
Step-by-Step Solution
Solution:
  1. Step 1: Check input type for generate_password_hash

    The function expects a string password, not an integer.
  2. Step 2: Identify the error cause

    Passing an integer causes a type error; converting to string fixes it.
  3. Final Answer:

    Password must be a string, not an integer -> Option D
  4. Quick Check:

    Passwords must be strings for hashing [OK]
Quick Trick: Always pass passwords as strings to hash functions [OK]
Common Mistakes:
MISTAKES
  • Passing numbers without converting to string
  • Assuming multiple arguments are required
  • Incorrect import statements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes