This commit is contained in:
parent
6107ffe99d
commit
a15d3e4dc7
@ -66,7 +66,7 @@ class NetWrapper:
|
|||||||
|
|
||||||
def authenticate(self, password: str):
|
def authenticate(self, password: str):
|
||||||
message = f"LIN {self.username} {password}".encode('UTF-8')
|
message = f"LIN {self.username} {password}".encode('UTF-8')
|
||||||
cipher = ChaCha20.new(self.cipherkey, get_random_bytes(12))
|
cipher = ChaCha20.new(key=self.cipherkey, nonce=get_random_bytes(12))
|
||||||
ciphertext = cipher.encrypt(message)
|
ciphertext = cipher.encrypt(message)
|
||||||
nonce = b64encode(cipher.nonce).decode('ASCII')
|
nonce = b64encode(cipher.nonce).decode('ASCII')
|
||||||
ct = b64encode(ciphertext).decode('ASCII')
|
ct = b64encode(ciphertext).decode('ASCII')
|
||||||
@ -101,7 +101,7 @@ class NetWrapper:
|
|||||||
|
|
||||||
|
|
||||||
def sendMessage(self, message: bytes):
|
def sendMessage(self, message: bytes):
|
||||||
cipher = ChaCha20.new(self.cipherkey, get_random_bytes(12))
|
cipher = ChaCha20.new(key=self.cipherkey, nonce=get_random_bytes(12))
|
||||||
ciphertext = cipher.encrypt(message)
|
ciphertext = cipher.encrypt(message)
|
||||||
nonce = b64encode(cipher.nonce).decode('ASCII')
|
nonce = b64encode(cipher.nonce).decode('ASCII')
|
||||||
ct = b64encode(ciphertext).decode('ASCII')
|
ct = b64encode(ciphertext).decode('ASCII')
|
||||||
@ -120,7 +120,7 @@ class NetWrapper:
|
|||||||
try:
|
try:
|
||||||
retnonce = b64decode(b64['nonce'])
|
retnonce = b64decode(b64['nonce'])
|
||||||
retciphertext = b64decode(b64['message'])
|
retciphertext = b64decode(b64['message'])
|
||||||
retcipher = ChaCha20.new(self.cipherkey, nonce=retnonce)
|
retcipher = ChaCha20.new(key=self.cipherkey, nonce=retnonce)
|
||||||
plaintext = retcipher.decrypt(retciphertext)
|
plaintext = retcipher.decrypt(retciphertext)
|
||||||
return plaintext
|
return plaintext
|
||||||
except Exception:
|
except Exception:
|
||||||
|
Loading…
Reference in New Issue
Block a user