You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.0 KiB
31 lines
1.0 KiB
# -*- coding: utf-8 -*-
|
|
|
|
import tkinter as tk
|
|
from random import randint
|
|
from Interface import Interface
|
|
|
|
|
|
class InterfaceClient(Interface):
|
|
def __init__(self):
|
|
Interface.__init__(self, "client")
|
|
self.helloButton = tk.Button(self, text="Hello", command=self.hello)
|
|
self.helloButton.pack()
|
|
self.keyButton = tk.Button(self, text="KeyExchange", command=keyexchange)
|
|
self.keyButton.pack()
|
|
|
|
def hello(self):
|
|
"envoie le message HELLO"
|
|
self.connexion.send("HELLO")
|
|
|
|
def keyexchange(self):
|
|
"""attend la clé publique du serveur, choisis une clé symétrique aleatoire de 7
|
|
caractères, la transmet en la chiffrant avec la clé publique du sevreur puis attend le message Finished"""
|
|
cle_publique = self.connexion.recv()
|
|
cle_symetrique = ""
|
|
for i in range(7):
|
|
chiffre = randint(1, 256)
|
|
cle_symetrique += chr(chiffre)
|
|
|
|
|
|
It = InterfaceClient()
|
|
It.mainloop()
|
|
|