diff options
author | clach04 <Chris.Clark@actian.com> | 2018-03-18T22·12-0700 |
---|---|---|
committer | Matthew Garrett <mjg59-github@srcf.ucam.org> | 2018-03-18T22·12-0700 |
commit | 8b593beff968caf47bf19e703e8fc3b1df3d5e6a (patch) | |
tree | e72a7462eb3cc7115a935a43f6a08411d5901355 /broadlink/__init__.py | |
parent | 8d3c9f1e9f7ad19f1c054ca3278670c8c9ea0eb1 (diff) |
Restore Python 3 support (#95)
Use explicit byte literals. AES encryption padding broken with commit f7e30344c5748e37924c8a4f28522c2bc99a52ee under Python 3. Python 3 support when using pyaes (instead of Crypto.Cipher.AES) now works.
Diffstat (limited to 'broadlink/__init__.py')
-rw-r--r-- | broadlink/__init__.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/broadlink/__init__.py b/broadlink/__init__.py index 910184a025dd..6a6636d1a3ef 100644 --- a/broadlink/__init__.py +++ b/broadlink/__init__.py @@ -182,11 +182,11 @@ class device: def encrypt_pyaes(self, payload): aes = pyaes.AESModeOfOperationCBC(self.key, iv = bytes(self.iv)) - return "".join([aes.encrypt(bytes(payload[i:i+16])) for i in range(0, len(payload), 16)]) + return b"".join([aes.encrypt(bytes(payload[i:i+16])) for i in range(0, len(payload), 16)]) def decrypt_pyaes(self, payload): aes = pyaes.AESModeOfOperationCBC(self.key, iv = bytes(self.iv)) - return "".join([aes.decrypt(bytes(payload[i:i+16])) for i in range(0, len(payload), 16)]) + return b"".join([aes.decrypt(bytes(payload[i:i+16])) for i in range(0, len(payload), 16)]) def encrypt_pycrypto(self, payload): aes = AES.new(bytes(self.key), AES.MODE_CBC, bytes(self.iv)) @@ -272,7 +272,7 @@ class device: # pad the payload for AES encryption if len(payload)>0: numpad=(len(payload)//16+1)*16 - payload=payload.ljust(numpad,b"\x00") + payload=payload.ljust(numpad, b"\x00") checksum = 0xbeaf for i in range(len(payload)): |