mirror of
https://github.com/mjg59/python-broadlink.git
synced 2024-11-22 15:10:12 +01:00
pad the payload for AES encryption (16) (#92)
This commit is contained in:
parent
f1d62380c9
commit
f7e30344c5
@ -245,6 +245,11 @@ class device:
|
||||
packet[0x32] = self.id[2]
|
||||
packet[0x33] = self.id[3]
|
||||
|
||||
# pad the payload for AES encryption
|
||||
if len(payload)>0:
|
||||
numpad=(len(payload)//16+1)*16
|
||||
payload=payload.ljust(numpad,"\x00")
|
||||
|
||||
checksum = 0xbeaf
|
||||
for i in range(len(payload)):
|
||||
checksum += payload[i]
|
||||
@ -539,4 +544,4 @@ def setup(ssid, password, security_mode):
|
||||
socket.SOCK_DGRAM) # UDP
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
|
||||
sock.sendto(payload, ('255.255.255.255', 80))
|
||||
sock.sendto(payload, ('255.255.255.255', 80))
|
||||
|
Loading…
Reference in New Issue
Block a user