From b33bbdbbcf1270fb77f346f0e003273247d3ff2f Mon Sep 17 00:00:00 2001 From: Felipe Martins Diel Date: Mon, 11 Jan 2021 17:51:31 -0300 Subject: [PATCH] Fix encryption errors (#505) --- broadlink/device.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/broadlink/device.py b/broadlink/device.py index 6a0c2de..e675377 100644 --- a/broadlink/device.py +++ b/broadlink/device.py @@ -154,18 +154,18 @@ class device: def update_aes(self, key: bytes) -> None: """Update AES.""" self.aes = Cipher( - algorithms.AES(key), modes.CBC(self.iv), backend=default_backend() + algorithms.AES(bytes(key)), modes.CBC(self.iv), backend=default_backend() ) def encrypt(self, payload: bytes) -> bytes: """Encrypt the payload.""" encryptor = self.aes.encryptor() - return encryptor.update(payload) + encryptor.finalize() + return encryptor.update(bytes(payload)) + encryptor.finalize() def decrypt(self, payload: bytes) -> bytes: """Decrypt the payload.""" decryptor = self.aes.decryptor() - return decryptor.update(payload) + decryptor.finalize() + return decryptor.update(bytes(payload)) + decryptor.finalize() def auth(self) -> bool: """Authenticate to the device."""