Browse Source

enabled/disabled

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

4
Interface.py

@ -15,9 +15,9 @@ class Interface(tk.Tk):
tk.Label(text="Message reçu : ").pack() tk.Label(text="Message reçu : ").pack()
self.message = tk.StringVar() self.message = tk.StringVar()
tk.Label(textvariable=self.message).pack() 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.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.recvButton.pack()
# #
self._cleSymetrique = None self._cleSymetrique = None

7
InterfaceClient.py

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

7
InterfaceServeur.py

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

Loading…
Cancel
Save