コード例 #1
0
    def login(self, username, password):
        """Takes the login information, ecrypts it, and prepares it to be sent to the server."""

        connection = self.sock
        connection.send("login".encode())
        status_code = connection.recv(2)
        if status_code != client_api.SUCCESS:
            print("Failled")
            return 0

        register = loginEncryption.LoginEncoding()
        register.setUsername(username)
        register.setPassword(password)
        username = register.getUsername()
        password = register.getPassword()

        login_info = "username:"******";password:" + password

        connection.send(login_info.encode())

        server_response = connection.recv(2)  # SUCCESS or FAILURE
        print(server_response.decode())
        if server_response == client_api.SUCCESS:
            repoids.clear()
            packed_repo_id = connection.recv(4)
            repo_id_tup = struct.unpack('<L', packed_repo_id)
            repo_id = repo_id_tup[0]
            repoids.append(repo_id)
            print(repo_id)
        else:
            return 0

        global_username.clear()
        global_username.append(username)
        return 1
コード例 #2
0
    def login(self, username, password):
        connection = self.sock
        connection.send("login".encode())
        print("Hello")
        status_code = connection.recv(2)
        print("MSG Replayed")
        if status_code != client_api.SUCCESS:
            print("Failled")
            return 0

        login_info = "username:"******";" + "password:" + password

        # print(login_info)

        connection.send(login_info.encode())
        # self.sock.send(login_info.encode())
        # connection.close()
        server_response = connection.recv(2)  # SUCCESS or FAILURE
        print(server_response.decode())
        if server_response == client_api.SUCCESS:
            repoids.clear()
            packed_repo_id = connection.recv(4)
            repo_id_tup = struct.unpack('<L', packed_repo_id)
            repo_id = repo_id_tup[0]
            repoids.append(repo_id)
            print(repo_id)
            return 1
        else:
            return 0
コード例 #3
0
    def register(self, username, password, sec_question, sec_answer):
        """Takes the parameters, hashes the password, encodes the username, and prepares it to be sent to server"""

        if self.connected == False:
            return 0
        connection = self.sock
        connection.send("register".encode())

        register = loginEncryption.LoginEncoding()
        register.setUsername(username)
        register.setPassword(password)
        username = register.getUsername()
        password = register.getPassword()

        register_info = "username:"******";password:"******";sec_question:" \
                        + sec_question + ";sec_answer:" + sec_answer
        connection.send(register_info.encode())
        server_response = connection.recv(2)
        if server_response == client_api.SUCCESS:
            repoids.clear()
            packed_repo_id = connection.recv(4)
            repo_id_tup = struct.unpack('<L', packed_repo_id)
            repo_id = repo_id_tup[0]
            repoids.append(repo_id)
            print(repo_id)
        else:
            return 0

        global_username.clear()
        global_username.append(username)
        return 1
コード例 #4
0
    def register(self, username, password):
        if self.connected == False:
            return 0  # Maybe change to a unique code stating we are not connected?
        connection = self.sock
        connection.send("register".encode())

        # credentials = LoginEncoding(username, password)
        # username = credentials.getUsername()
        # password = credentials.getPassword()
        # key = credentials.getKey()

        register_info = "username:"******";" + "password:" + password
        connection.send(register_info.encode())
        server_response = connection.recv(2)
        if server_response == client_api.SUCCESS:
            repoids.clear()
            packed_repo_id = connection.recv(4)
            repo_id_tup = struct.unpack('<L', packed_repo_id)
            repo_id = repo_id_tup[0]
            repoids.append(repo_id)
            print(repo_id)
            return 1
        else:
            return 0