I am using Flask for a web login page. I am trying to exploit sha256 password encryption, but I have no idea why line sha256_crypt.verify(password,pass_data)
is throwing with the error in title.
Is there anything I am missing? If I can give more details please ask, maybe providing some instructions on how to debug. Thank you.
@app.route("/login", methods=["GET","POST"])
def login():
if request.method == "POST":
username= str(request.form['username'])
password = request.form.get('password')
cursor = mydb.cursor(MySQLdb.cursors.DictCursor)
cursor.execute("SELECT * FROM user WHERE username ='"+ username +"'")
userdata = cursor.fetchone()
usernamedata = userdata['username']
passworddata = userdata['password']
if usernamedata is None:
flash("Incorrect username","danger")
return render_template("login.html")
else:
for pass_data in passworddata:
if sha256_crypt.verify(password,pass_data):
flash("You are now login","success")
return redirect(url_for('profile'))
else:
flash("Incorrect password!")
return render_template("login.html")
return render_template("login.html")