def session(conn_receive, cp_receive, conn_send, cp_send, name): while True: line = conn_receive.recv() if line is not None: import gui if line != '': line = cp_receive.decrypt(line) gui.add_new_text("[" + name + "] " + line) conn_send.send(cp_send.encrypt(line)) else: break
dh = DiffieHellman(p, g) _, _, B = dh.generate_public_broadcast() conn.send(str(B)) crypto_protocol = CryptoProtocol(dh.get_shared_secret(A)) else: print "Unreachable code reached!!!" sys.exit() def send_message(text): conn.send(crypto_protocol.encrypt(text)) class GUIThread(threading.Thread): def run(self): import gui gui.set_send_message_callback(send_message) gui.start() GUIThread().start() while True: line = conn.recv() if line is not None: import gui if line != '': gui.add_new_text("[Other] " + crypto_protocol.decrypt(line)) else: break