0
0
Flaskframework~10 mins

Password hashing with Werkzeug in Flask - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the function used for hashing passwords.

Flask
from werkzeug.security import [1]
Drag options to blanks, or click blank then click option'
Agenerate_password_hash
Bcheck_password_hash
Chash_password
Dpassword_hash
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong function like check_password_hash
Using a non-existent function name
2fill in blank
medium

Complete the code to hash the password string 'mypassword'.

Flask
hashed = generate_password_hash([1])
Drag options to blanks, or click blank then click option'
A'mypassword'.encode('utf-8')
B'mypassword'
Cb'mypassword'
Dmypassword
Attempts:
3 left
💡 Hint
Common Mistakes
Passing bytes instead of string
Passing a variable not defined
3fill in blank
hard

Fix the error in the code to verify a password against its hash.

Flask
check_password_hash([1], 'mypassword')
Drag options to blanks, or click blank then click option'
Ahashed_password
B'hashed_password'
Cpassword_hash
Dhash_password
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the variable name as a string
Using an undefined variable
4fill in blank
hard

Fill both blanks to hash a password with method 'pbkdf2:sha256' and salt length 16.

Flask
hashed = generate_password_hash('secret', method=[1], salt_length=[2])
Drag options to blanks, or click blank then click option'
A'pbkdf2:sha256'
B16
C'sha256'
D8
Attempts:
3 left
💡 Hint
Common Mistakes
Using just 'sha256' as method
Using too small salt length
5fill in blank
hard

Fill all three blanks to check a password and print a message if it matches.

Flask
if check_password_hash([1], [2]):
    print([3])
Drag options to blanks, or click blank then click option'
Ahashed_pw
B'user_input'
C'Password is correct!'
D'Password matches'
Attempts:
3 left
💡 Hint
Common Mistakes
Using string literals instead of variables
Printing unclear messages