Python Forum
TypeError: '>=' not supported between instances of 'int' and 'str'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: '>=' not supported between instances of 'int' and 'str'
#4
(Mar-10-2021, 05:57 PM)buran Wrote: Please, post the full traceback you get, verbatim, not just the last line.
Also the full code, e.g. what is new_pass?

Okay.

Server:
import socket

from cryptotools import RSA, PrivateKey

hashed = None
Content = None
Password = None
File = None
f = None
feil = None
FileLoc = None
UUID = None
AccountExists = None
rawUUID = None
key = PrivateKey.random()
pkey = key.to_public()


def server_program():
    # get the hostname
    global hashed, Content, Password, f, File, feil, FileLoc, rawUUID, AccountExists, UUID
    host = "127.0.0.1"
    port = 65432  # initiate port no above 1024

    server_socket = socket.socket()  # get instance
    # look closely. The bind() function takes tuple as argument
    server_socket.bind((host, port))  # bind host address and port together

    # configure how many client the server can listen simultaneously
    server_socket.listen(2)
    conn, address = server_socket.accept()  # accept new connection
    print("Connection from: " + str(address))
    while True:
        # receive data stream. it won't accept data packet greater than 1024 bytes
        data = conn.recv(1024).decode()
        if data != "":
            print(data)
        if not data:
            break
        if data[0:4] == "PSWD":  # PSWD
            Password = data.split("PSWD")[1]
            try:
                AccountExists = open("logins.txt", 'w+').read().split(Password)[1]
            except IndexError as e:
                conn.sendall(RSA.Message.from_hex(b'AccountDoesntExist').encrypt(UUID))
                print(e)
                continue
            PSWD = AccountExists.split("\n")[0]
            if PSWD == Password:
                conn.sendall(RSA.Message.from_hex(b'True').encrypt(UUID))
            else:
                conn.sendall(RSA.Message.from_hex(b'False').encrypt(UUID))
        elif data[0:4] == "UUID":  # UUID
            Content = data.split("UUID")[1]
            UUID = Content
            msg = f'{pkey}'
            conn.sendall(msg.encode())
    server_socket.close()
    server_program()


if __name__ == '__main__':
    server_program()
Client:
import socket

from cryptotools import PrivateKey, RSA

HOST = "127.0.0.1"
PORT = 65432
private = PrivateKey.random()
public = private.to_public()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
msg = f'UUID{public}'
s.sendall(msg.encode())
serverkey = s.recv(1024).decode()
new_pass = input('Please enter a password: ')
msg = f'PSWD{RSA.Message.from_hex(new_pass).encrypt((serverkey[0], serverkey[1]))}'
s.sendall(msg.encode())
rawdata = s.recv(1024).decode()
Recieved = RSA.Message.from_hex(rawdata).decrypt(private)
s.close()
print(Recieved)
Reply


Messages In This Thread
RE: TypeError: '>=' not supported between instances of 'int' and 'str' - by helpme1 - Mar-10-2021, 06:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sort Function: <' not supported between instances of 'float' and 'tuple' quest 2 8,156 Apr-30-2021, 07:37 PM
Last Post: quest
  Type error: '>' not supported between instances of 'NoneType' and 'int' spalisetty06 1 10,529 Apr-29-2020, 06:41 AM
Last Post: buran
  TypeError: '<' not supported between instances of 'str' and 'int' Svensation 5 8,926 Jan-20-2020, 08:12 PM
Last Post: buran
  TypeError: Not supported between instances of 'function' and 'int' palladium 9 19,798 Dec-06-2019, 12:40 AM
Last Post: palladium
  TypeError: '>=' not supported between instances of 'str' and 'int' AsadZ 8 10,682 Aug-20-2019, 11:45 AM
Last Post: ThomasL
  '>' not supported between instances of 'str' and 'int' graham23s 2 4,024 May-11-2019, 07:09 PM
Last Post: micseydel
  Newbie Question re "TypeError: '<' not supported between instances of 'list' and 'int sr12 8 13,168 Apr-11-2019, 08:19 PM
Last Post: sr12
  '<' not supported between instances of 'str' and 'int' jayaherkar 1 7,984 Apr-09-2019, 03:25 PM
Last Post: perfringo
  TypeError: '<' not supported between instances of 'int' and 'builtin_function_or_meth yann2771 1 5,610 Mar-05-2019, 09:51 PM
Last Post: stranac
  '<=' not supported between instances of 'str' and 'int' Loom 1 7,824 Aug-11-2018, 07:34 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020