Using Python and Flask I've created register page with name, email, password and confirm password fields. In order to store passwords in the DB in encrypted format I went for passlib. I've reached a point where this code doesn't work which is to be expected according to the documentation:
name = request.form['name']
email = request.form['email']
password = pbkdf2_sha256.hash(str(request.form['pass']))
confirm = pbkdf2_sha256.hash(str(request.form['confirm']))
if password == confirm:
cur = mysql.connection.cursor()
cur.execute("INSERT INTO users(name, email, password) VALUES(%s, %s, %s)", (name, email, password))
mysql.connection.commit()
but this works
name = request.form['name']
email = request.form['email']
password = pbkdf2_sha256.hash(str(request.form['pass']))
confirm = request.form['confirm']
if pbkdf2_sha256.verify(confirm, password):
cur = mysql.connection.cursor()
cur.execute("INSERT INTO users(name, email, password) VALUES(%s, %s, %s)", (name, email, password))
mysql.connection.commit()
Although I'm not sure if this is the right way to do it. I'd appreciate some advices.