return (hardware_address_xor, link_key_b64)
+def make_hardware_address_xor(device_address):
+ # the hardware_address_xor from device_address 000d6f000273ce0b
+ # should match the hardware_address_xor from claim_code
+ # ps2f-gsjg-8wsq-7hc4
+ b = bytearray.fromhex(device_address)
+
+ claim_address = bytearray(3)
+ claim_address[0] = b[0] ^ b[5]
+ claim_address[1] = b[1] ^ b[3] ^ b[6]
+ claim_address[2] = b[2] ^ b[4] ^ b[7]
+
+ result = claim_address[2] << 16 | claim_address[1] << 8 | claim_address[0]
+
+ return result
# ~~~~
# Test
from PIL import Image
from itertools import groupby
-import array
import struct
WHITE = 0
lengths = [g[1] for g in groups]
x = bytearray(rle(lengths))
compressed_data = struct.pack("<%dB" % len(x), *x)
+
+ # package up with length as header
# first byte is compressed type, always 1
output = struct.pack("<BL", 0x01, len(compressed_data)) + compressed_data
for length, code in TRANSLATE:
length_codes[code] = length
- for b in rle_encoded:
+ for b in rle_encoded[3:]: # jump the header bytes
length = ord(b)
if length in length_codes.keys():
length = length_codes[length]