def register(self, username, password, code):
#Query met parameters
sqlQuery = "Select * from tbl_users WHERE username = '{param1}'"
sqlCommand = sqlQuery.format(param1=username)
self.__cursor.execute(sqlCommand)
result = self.__cursor.fetchone()
if int(code) == 25081998:
if result:
message = "Error: Deze gebruiker bestaat al"
else:
pwd_bytes = password
salt_bytes = os.urandom(16)
hash_bytes = hashlib.pbkdf2_hmac('sha256', pwd_bytes, salt_bytes, 100000)
salt_string = binascii.hexlify(salt_bytes).decode('utf-8')
hash_string = binascii.hexlify(hash_bytes).decode('utf-8')
sqlQuery2 = "INSERT INTO tbl_users (username, pwd_hash, pwd_salt) VALUES ('{param1}', '{param2}', '{param3}')"
sqlCommand2 = sqlQuery2.format(param1=username, param2=hash_string, param3=salt_string)
self.__cursor.execute(sqlCommand2)
self.__connection.commit()
self.__cursor.close()
message = "Succesvol geregistreerd"
else:
message = "Error: Foute code"
return message
评论列表
文章目录