Browse Source

enabled/disabled

master
corentin.bollet 6 months ago
parent
commit
ba4b57fc3a
  1. 4
      Interface.py
  2. 9
      InterfaceClient.py
  3. 7
      InterfaceServeur.py

4
Interface.py

@ -15,9 +15,9 @@ class Interface(tk.Tk):
tk.Label(text="Message reçu : ").pack()
self.message = tk.StringVar()
tk.Label(textvariable=self.message).pack()
self.sendButton = tk.Button(self, text="Send", command=self.send)
self.sendButton = tk.Button(self, text="Send", command=self.send, state="disabled")
self.sendButton.pack()
self.recvButton = tk.Button(self, text="Receive", command=self.receive)
self.recvButton = tk.Button(self, text="Receive", command=self.receive, state="disabled")
self.recvButton.pack()
#
self._cleSymetrique = None

9
InterfaceClient.py

@ -11,13 +11,15 @@ class InterfaceClient(Interface):
# à compléter
self.sendHelloButton = tk.Button(self, text="Hello", command=self.hello)
self.sendHelloButton.pack()
self.keyExchangeButton = tk.Button(self, text="KeyExchange", command=self.keyExchange)
self.keyExchangeButton = tk.Button(self, text="KeyExchange", command=self.keyExchange, state="disabled")
self.keyExchangeButton.pack()
def hello(self):
"""envoie en clair le message HELLO"""
self.entree.set("HELLO")
self.send()
self.sendHelloButton['state'] = "disabled"
self.keyExchangeButton['state'] = "enable"
def keyExchange(self):
"""attend la clé publique du serveur
@ -39,6 +41,9 @@ class InterfaceClient(Interface):
self.receive()
if self.message.get() == "Finished":
print("Connection sécurisée établie ☺")
self.keyExchangeButton['state'] = "disabled"
self.sendButton['state'] = "enabled"
self.recvButton['state'] = "enabled"
def chiffre_RSA(self, msg, cle):
"""chiffre un message avec une clé publique"""

7
InterfaceServeur.py

@ -13,7 +13,7 @@ class InterfaceServeur(Interface):
# à compléter
self.waitForHelloButton = tk.Button(self, text="Serveur Hello", command=self.hello)
self.waitForHelloButton.pack()
self.finishedButton = tk.Button(self, text="Finished", command=self.finish)
self.finishedButton = tk.Button(self, text="Finished", command=self.finish, state="disabled")
self.finishedButton.pack()
def hello(self):
@ -23,6 +23,8 @@ class InterfaceServeur(Interface):
if self.message.get() == "HELLO":
self.entree.set(str(self.e)+";"+str(self.n))
self.send()
self.waitForHelloButton['state'] = 'disabled'
self.finishedButton['state'] = 'enabled'
else:
print("HELLO n'a pas été reçu.")
@ -35,6 +37,9 @@ class InterfaceServeur(Interface):
self.set_cleSymetrique(cleSym_dechiffree)
self.entree.set("Finished")
self.send()
self.finishedButton['state'] = "disabled"
self.sendButton['state'] = "enabled"
self.recvButton['state'] = "enabled"
def dechiffre_RSA(self, msg):
"""déchiffre un message avec sa clé privée"""

Loading…
Cancel
Save