파이썬과 플라스크를 사용하여 webapp를 개발하고 있습니다. 그것에는 사용자 시스템이 있습니다. 물론 등록 양식이 있습니다. passwib.hash.sha256을 등록하고자하는 사용자의 암호를 암호화하기 위해 사용하고 있습니다. 여기에 내가 뭐하는 거지의 : 데이터베이스에서 sha256_crypt.encrypt 항상 다른 해시를 반환합니다.
from passlib.hash import sha256_crypt as sha256
[...]
if request.method == "POST" and form.validate():
username = request.form['username']
password = request.form['password']
confirm_password = request.form['confirm_password']
email = request.form['email']
password = sha256.encrypt(password) #Encryption.
c, conn = connection('accounts') #Connection to the database
x = c.execute("SELECT * FROM accounts WHERE username = '%s' OR email = '%s'" %(thwart(username), thwart(email)))
if x:
flash("We are very sorry, but this Username/Email-address is already taken. Please try again")
else:
c.execute('INSERT INTO accounts VALUES ("%s", "%s", "%s")' %(thwart(username), thwart(password), thwart(email)))
conn.commit()
flash('Succesfully Registered!')
가, 해시는 항상 동일한 암호가 inputed 된 경우에도, 다양한있다. 왜 아무도 알지 못해? 내가 도대체 뭘 잘못하고있는 겁니까?
소금 https://en.wikipedia.org/wiki/Salt_(cryptography). 인증을 처리 할 정도로 자격이 있다고 확신합니까? –
"자격이 있음"이 의미하는 바는 – MisterMM23
입니다. 그러나 무작위 데이터를 추가하는 프로그램은 작성하지 않았습니다. 이건 파이썬의 sha256에 새로운가요? – MisterMM23