pep8
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Torma Kristóf 2021-04-24 23:41:34 +02:00
parent 281af0fb2e
commit 9dc4cab674
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
1 changed files with 7 additions and 5 deletions

View File

@ -23,7 +23,7 @@ class NetWrapper:
self.username = username
self.privateKey = privateKey
self.serverPubKey = serverPubKey
self.cipherkey="".encode('UTF-8')
self.cipherkey = "".encode('UTF-8')
def randomStringGenerator(self, str_size: int = 512,
allowed_chars: str = string.ascii_letters + string.punctuation) -> str:
@ -53,7 +53,7 @@ class NetWrapper:
cipher = PKCS1_OAEP.new(rsakey)
mypubkey = b64encode(cipher.encrypt(str(dh.gen_public_key()).encode('UTF-8')))
jsonmsg = json.dumps({'type': 'DH', 'source': self.network.own_addr, 'message': mypubkey}).encode('UTF-8')
self.network.send_msg(self.serverAddr,jsonmsg)
self.network.send_msg(self.serverAddr, jsonmsg)
status, msg = self.network.receive_msg(blocking=True)
if not status:
raise Exception('Network error during connection.')
@ -69,7 +69,8 @@ class NetWrapper:
ciphertext = cipher.encrypt(message)
nonce = b64encode(cipher.nonce).decode('UTF-8')
ct = b64encode(ciphertext).decode('UTF-8')
sendjson = json.dumps({'type': 'AUT', 'source': self.network.own_addr, 'nonce': nonce, 'message': ct}).encode('UTF-8')
sendjson = json.dumps({'type': 'AUT', 'source': self.network.own_addr, 'nonce': nonce, 'message': ct}).encode(
'UTF-8')
self.network.send_msg(self.serverAddr, sendjson)
status, msg = self.network.receive_msg(blocking=True)
if not status:
@ -99,8 +100,9 @@ class NetWrapper:
ciphertext = cipher.encrypt(message)
nonce = b64encode(cipher.nonce).decode('UTF-8')
ct = b64encode(ciphertext).decode('UTF-8')
sendjson = json.dumps({'type': 'CMD', 'source': self.network.own_addr, 'nonce': nonce, 'message': ct}).encode('UTF-8')
self.network.send_msg(self.serverAddr,sendjson)
sendjson = json.dumps({'type': 'CMD', 'source': self.network.own_addr, 'nonce': nonce, 'message': ct}).encode(
'UTF-8')
self.network.send_msg(self.serverAddr, sendjson)
def recieveMessage(self) -> bytes:
status, msg = self.network.receive_msg(blocking=True)