This commit is contained in:
parent
9b5b1c9eb0
commit
2412412ff6
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user