#π deleted
36 messages Β· Page 1 of 1 (latest)
@obtuse kiln
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
just bc i see something. are you hashing the password before or after the client sends to the server?
this is the login method:
def login_user(self, username, password):
try:
print("Logging in user...")
if not self.connected:
print("Not connected to the server. Please connect first.")
return
# Hash the password before sending
hashed_password = authUtils.hash_password(password)
# Send the login command to the server
self.socket.sendall(b"login")
# Send username and hashed password to the server
message = f"{username},{hashed_password}"
self.socket.sendall(message.encode())
# Receive login result from the server
response = self.socket.recv(1024).decode()
print("Received message from server:", response)
except Exception as e:
print(f"An error occurred while logging in: {e}")
so, what you actually do is sends the password and then have the server hash it. hashing it client side makes the hash the password not the password itself. that might be your problem depending on how you compare hashes bc its not hash = hash. an SSL certificate takes care of encrypting the nonhashed password on its way to the server, the server only hashes it for storage and comparison but needs to get the raw password so it can do that
can you show how you compare the hashes?
you can safely ignore my advice on hashing server side depending on what youre doing but seeing as its accounts im going to say its probably at least a good idea to get into how to do it right
i think youve found the error, im really spun within my own project (i modularized early and this is making it hard for me to keep track of things). ill report back if i can even un-spaghetti this to make sure the hashing is happening server side
remember this chat closes after an hour of no messages, but good luck
i really cant even conceptually answer your questions short of sending the project (its 6 tiny modules, is that allowed here?) ive been stuck for about 6 hours on this. i dont understand SQL very much at all
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
done
not an issue to do multiple paste but its more work on you XD there is add another file button on the bottom right
good for future efforts
i was battling a threading error for like 6 hours and now it just wont login at all
alright ive got to go now, but if you cant get the help you need here feel free to dm me. do try to get help here first though
hows the unspaghetti going @obtuse kiln
not at all, im not sufficiently trained to understand the problem im having. ive been bashing my head against it asking the questions in different capacities to LLMs with code snippets and stackoverflow but nothing makes sense. theres an error somewhere where the passed off information isnt expected as it is or somethings missing but its just too dense for me to understand
if i had the time id delve into it with you
Before I approach this further... How proficient are you in Python using https://docs.python.org/3/tutorial as a reference? Do you think you can migrate your server to use socketserver instead of socket and threading yourself? It will clean up your code significantly. Did you make sure sqlite3.threadsafety is 3 before proceeding to carelessly use a database connection in this multithreaded server?
In the meantime, I'm reading the authentication mechanism to see why it fails
nearly 0%. my method of coding is asking an LLM to design a boilerplate function and then adding prints to watch for errors, correcting by gradient descent. honestly im very close to trashing the project because i cant even comprehend which script has the problem therefore i cant add prints to figure out what the real issue is. i can design a game in python and pygame pretty easily but networking seems like mysticism to me and defeats my soul entirely, almost no exaggeration here. I used a DB inspecting program to see that it does indeed write the same username and hashed password exactly but then wont login with it, so..im lost
LLM creep got away from me, when i first made this project before dumping it a couple months ago i was ontop of understanding everything immediately as it was handed to me, but this time i let it modularize (take a large script and move it into a smaller script for readability) pretty early and thus ive lost sight of the location of the error
You are in fact hashing the password on the server twice before comparing it with the hash stored in the database
Let the authManager hash it and don't bother doing so in the server class
applying advice now
im having db connection issues now, what fun. π i probably need to scrap this entirely and redo it
Does your newfound knowledge help
I mean
I'd recommend learning Python before delving into a project like this anyway
You should also be aware that socket connections have a lot of complexity that you aren't handling properly here
i scrapped the project, please disregard and i no longer need responses
deleted
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.