Skip to content

Commit

Permalink
Fix encryption errors
Browse files Browse the repository at this point in the history
  • Loading branch information
felipediel committed Jan 23, 2021
1 parent 5ebfb1f commit 4dfda47
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions broadlink/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,18 @@ def __str__(self):
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."""
Expand Down

0 comments on commit 4dfda47

Please sign in to comment.