From 2412412ff6b18718b096631c996a8e1cb45bd79b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torma=20Krist=C3=B3f?= Date: Sun, 25 Apr 2021 17:03:13 +0200 Subject: [PATCH] use ascii --- client/netwrapper.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/netwrapper.py b/client/netwrapper.py index 1d3b5a8..eb082ef 100644 --- a/client/netwrapper.py +++ b/client/netwrapper.py @@ -33,7 +33,7 @@ class NetWrapper: cipher_rsa = PKCS1_OAEP.new(self.serverPubKey) identMsg = json.dumps( {'type': 'IDY', 'source': self.network.own_addr, 'username': self.username, - 'message': b64encode(cipher_rsa.encrypt(randommsg.encode('UTF-8'))).decode()}).encode( + 'message': b64encode(cipher_rsa.encrypt(randommsg.encode('UTF-8'))).decode('ASCII')}).encode( 'UTF-8') self.network.send_msg(self.serverAddr, identMsg) returnJson = {'source': '', 'type': ''} @@ -50,7 +50,7 @@ class NetWrapper: def createEncryptedChannel(self): dh = pyDH.DiffieHellman() cipher_rsa = PKCS1_OAEP.new(self.serverPubKey) - mypubkey = b64encode(cipher_rsa.encrypt(str(dh.gen_public_key()).encode('UTF-8'))) + mypubkey = b64encode(cipher_rsa.encrypt(str(dh.gen_public_key()).encode('UTF-8'))).decode('ASCII') jsonmsg = json.dumps({'type': 'DH', 'source': self.network.own_addr, 'message': mypubkey}).encode('UTF-8') self.network.send_msg(self.serverAddr, jsonmsg) decodedmsg = {'source': '', 'type': ''} @@ -68,8 +68,8 @@ class NetWrapper: message = f"LIN {self.username} {password}".encode('UTF-8') cipher = ChaCha20.new(self.cipherkey, get_random_bytes(12)) ciphertext = cipher.encrypt(message) - nonce = b64encode(cipher.nonce).decode('UTF-8') - ct = b64encode(ciphertext).decode('UTF-8') + nonce = b64encode(cipher.nonce).decode('ASCII') + ct = b64encode(ciphertext).decode('ASCII') sendjson = json.dumps({'type': 'AUT', 'source': self.network.own_addr, 'nonce': nonce, 'message': ct}).encode( 'UTF-8') self.network.send_msg(self.serverAddr, sendjson) @@ -103,8 +103,8 @@ class NetWrapper: def sendMessage(self, message: bytes): cipher = ChaCha20.new(self.cipherkey, get_random_bytes(12)) ciphertext = cipher.encrypt(message) - nonce = b64encode(cipher.nonce).decode('UTF-8') - ct = b64encode(ciphertext).decode('UTF-8') + nonce = b64encode(cipher.nonce).decode('ASCII') + ct = b64encode(ciphertext).decode('ASCII') sendjson = json.dumps({'type': 'CMD', 'source': self.network.own_addr, 'nonce': nonce, 'message': ct}).encode( 'UTF-8') self.network.send_msg(self.serverAddr, sendjson)