From 12ba8663271d07cd122a34d50258c6cd754054a3 Mon Sep 17 00:00:00 2001 From: Matt Webb Date: Mon, 22 Sep 2014 21:10:04 +0100 Subject: [PATCH] add hardware_address_xor --- app/claiming.py | 14 ++++++++++++++ app/image_encoding.py | 5 +++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/claiming.py b/app/claiming.py index 95ad768..a2a18a1 100755 --- a/app/claiming.py +++ b/app/claiming.py @@ -147,6 +147,20 @@ def process_claim_code(claim_code): 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 diff --git a/app/image_encoding.py b/app/image_encoding.py index b66c608..3a9f36a 100644 --- a/app/image_encoding.py +++ b/app/image_encoding.py @@ -1,6 +1,5 @@ from PIL import Image from itertools import groupby -import array import struct WHITE = 0 @@ -73,6 +72,8 @@ def rle_image(image_fn): 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("