In the code below, I am attempting to decrypt a padded AES piece of text sent over TCP to my server.py file from a separate file named "client.py":
def handle(client):
while True:
try:
message = client.recv(1026)
key_iv = AES.new(b'5TGB&YHN7UJM(IK<', AES.MODE_CBC, b'!QAZ2WSX#EDC4RFV')
decrypt1 = key_iv.decrypt(message)
decrypt2 = decrypt1[0:len(text)]
broadcast(decrypt2)
time.sleep(2)
To do this, I must import the variable "text" from client.py via 'from client import text
'. Though, after I do this and then attempt to start up my server, I am shown a error that is only specific on the client file. The error shows 'Connection timed out, probably host is down
' and the code to show such a message is only present in the client.py file (shown below):
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
IP = '192.168.68.166'
PORT = 4444
try:
client.connect((IP, PORT))
username = input("Username: ")
except socket.error:
print("Connection timed out, probably host is down")
client.close()
sys.exit()
I know for a fact I am not experiencing socket errors when starting up my server and - even if I was - I should not be being shown an error from a piece of code I never imported