Essentially password_hash uses a one-way function to create a hash that is not reversible. Additionally it adds information to the hash such as the hash algorithm, salt value, iteration count and of course the hash value, this is what is stored. password_verify takes the password and the additional information in the result of password_hash to again create the hash and compares the hash values.
Additionally and importantly password_hash iterates over the hash function to make the process take longer, a good value is 100ms. Thus the best an attacker can do it try passwords to find one that matches and each attempt takes a substantial amount of time. Of course faster computational systems can reduce the ~100ms but it is still costly.
python - werkzeug generate_password_hash, is there any point? - Stack Overflow
ralph 3.0 admin login info ?
python - Why is the output of werkzeugs `generate_password_hash` not constant? - Stack Overflow
python - How can I authorize using werkzeug when accessed via Javascript? - Stack Overflow
I am getting werkzeug.routing.exceptions.BuildError: Could not build url for endpoint 'login'. Did you mean 'admin.login' instead?
after trying to login to my dashboard. Here's the code:
admin.py
admin_page = Blueprint('admin', __name__, template_folder='templates/admin', static_folder='static/admin')
@admin_page.route('/login/', methods=['GET', 'POST'])
def login():
form = LoginForm()
if form.validate_on_submit():
username = request.form['username']
password = request.form['password']
user = User.query.filter_by(username=username).first()
if user and user.check_password(password):
login_user(user)
flash("Login Successful", "success")
return redirect(request.args.get('next') or url_for('admin.admin_dashboard'))
else:
flash("Invalid Credentials", "danger")
return redirect(url_for('admin.login'))
return render_template("admin/login.html", form=form)
@admin_page.route('/dashboard/')
@login_required
def admin_dashboard():
return render_template('dashboard.html')I tried commenting out the redirect in if user and user.check_password(password) block to check whether I am being logged in, and I was. I tried removing and adding admin in admin.login and admin.dashboard but I am still getting the same error. what should I modify in this code?