List of Questions
Questions Related to Data Base
1.Explain your models?
It is related to your models.py file but common model is user for example :
(or)
2.What if a hacker gains access to your database?
To secure user passwords, it's important to implement a password security feature. One common approach is to use hashing to store passwords. Hashing is a one-way function, meaning it cannot be reversed. Even if an attacker gets access to the database, they won't be able to retrieve the original passwords because the hashed values do not reveal the actual password. This adds a strong layer of protection against unauthorized access.
To secure user passwords, it's important to implement a password security feature. One common approach is to use hashing to store passwords. Hashing is a one-way function, meaning it cannot be reversed. Even if an attacker gets access to the database, they won't be able to retrieve the original passwords because the hashed values do not reveal the actual password. This adds a strong layer of protection against unauthorized access.
3.what is werkzeug security?
Werkzeug security is a built-in part of the Flask ecosystem that helps you safely store and check passwords.
You should never store plain passwords in a database. Instead, you hash them which turns the password into a scrambled, unreadable string.
Werkzeug helps you do this easily using two main functions:
1. generate_password_hash(password)
-
Takes a plain password (like
"mypassword") -
Returns a hashed version of it
-
This hash is what you store in the database
2. check_password_hash(hashed_password, password)
-
Compares a plain password with the hashed one
-
Returns
Trueif they match
For this you have to import
from werkzeug.security import generate_password_hash, check_password_hash
hashed_password = generate_password_hash("mypassword")
check_password_hash(hashed_password, "mypassword")
No comments:
Post a Comment