def __init__(self, host, port, window): # attributs du serveur self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.host = host self.port = port self.window = window # attributs du client self.client = None self.clientList = [] # liste des clients self.adresseList = [] # liste des adresses ip + ports self.clientNumber = 0 self.currentClientListener = 0 self.currentClientSender = 0 self.pseudo = None self.pseudoList = [] # attributs liés au chiffrement RSA self.rsa = RSA_Cipher.RSAChiffrement() self.publicKeyRSA, self.privateKeyRSA = self.rsa.generateKeys() # attributs liés au chiffrement AES self.aes = AES_Cipher.AESChiffrement() self.AesKey = [] # debug self.window.lineEdit.setPlaceholderText('test test test zebi') print(self.publicKeyRSA.decode('ascii')) print(self.privateKeyRSA.decode('ascii')) print('[~] Server is ready ! [~]')
def __init__(self, host, port): self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.host = host self.port = port self.pseudo = None # attributs liés au chiffrement RSA self.rsa = RSA_Cipher.RSAChiffrement() self.RsaPublicKey = None # attributs liés au chiffrement AES self.aes = AES_Cipher.AESChiffrement() self.AesKey = None
def encrypt(passKey, cipher, dataformat, plaintext=None, filename=None, filepath=None, cipherMode=None): """ Checks the cipher used and returns the requested encrypted data """ # If the data format is message, a plaintext argument will need to be passed. if dataformat == "Messages": if cipher == "Caesar Cipher": encryptedData = Caesar_Cipher.encrypt(plaintext=plaintext, passKey=passKey, dataformat=dataformat, cipherMode=cipherMode) elif cipher == "Vigenere Cipher": encryptedData = Vigenere_Cipher.encrypt(plaintext=plaintext, passKey=passKey, dataformat=dataformat, cipherMode=cipherMode) elif cipher == "DES Cipher": encryptedData = DES_Cipher.encrypt(plaintext=plaintext, passKey=passKey, dataformat=dataformat) elif cipher == "Triple DES Cipher": encryptedData = DES_Cipher.encrypt(plaintext=plaintext, passKey=passKey, dataformat=dataformat, isTripleDES=True) elif cipher == "AES Cipher": encryptedData = AES_Cipher.encrypt(plaintext=plaintext, passKey=passKey, dataformat=dataformat) elif cipher == "RC4 Cipher": encryptedData = RC4_Cipher.encrypt(plaintext=plaintext, passKey=passKey, dataformat=dataformat) # If the data format is either a file or an image, a filename argument will need to be passed. else: if cipher == "Caesar Cipher": encryptedData = Caesar_Cipher.encrypt(filename=filename, filepath=filepath, passKey=passKey, dataformat=dataformat, cipherMode=cipherMode) elif cipher == "Vigenere Cipher": encryptedData = Vigenere_Cipher.encrypt(filename=filename, filepath=filepath, passKey=passKey, dataformat=dataformat, cipherMode=cipherMode) elif cipher == "DES Cipher": encryptedData = DES_Cipher.encrypt(filename=filename, filepath=filepath, passKey=passKey, dataformat=dataformat, cipherMode=cipherMode) elif cipher == "Triple DES Cipher": encryptedData = DES_Cipher.encrypt(filename=filename, filepath=filepath, passKey=passKey, dataformat=dataformat, cipherMode=cipherMode, isTripleDES=True) elif cipher == "AES Cipher": encryptedData = AES_Cipher.encrypt(filename=filename, filepath=filepath, passKey=passKey, dataformat=dataformat, cipherMode=cipherMode) elif cipher == "RC4 Cipher": encryptedData = RC4_Cipher.encrypt(filename=filename, filepath=filepath, passKey=passKey, dataformat=dataformat, cipherMode=cipherMode) return encryptedData