#πŸ”’ deleted

36 messages Β· Page 1 of 1 (latest)

sonic kayakBOT
#

@obtuse kiln

Python help channel opened

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.

slate surge
#

just bc i see something. are you hashing the password before or after the client sends to the server?

obtuse kiln
# slate surge just bc i see something. are you hashing the password before or after the client...

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}")
slate surge
#

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

obtuse kiln
#

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

slate surge
#

remember this chat closes after an hour of no messages, but good luck

obtuse kiln
#

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

slate surge
#

!paste

sonic kayakBOT
#
Pasting large amounts of code

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.

obtuse kiln
slate surge
#

not an issue to do multiple paste but its more work on you XD there is add another file button on the bottom right

obtuse kiln
#

i was battling a threading error for like 6 hours and now it just wont login at all

slate surge
#

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

obtuse kiln
# slate surge hows the unspaghetti going <@456226577798135808>

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

slate surge
#

if i had the time id delve into it with you

tight trench
# obtuse kiln gameClient.py: https://paste.pythondiscord.com/SA2Q gameServer.py: https://paste...

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

obtuse kiln
# tight trench Before I approach this further... How proficient are you in Python using https:/...

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

obtuse kiln
tight trench
#

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

obtuse kiln
tight trench
#

Does your newfound knowledge help

#

I mean

#

I'd recommend learning Python before delving into a project like this anyway

craggy nacelle
obtuse kiln
#

deleted

sonic kayakBOT
#
Python help channel closed

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.