def process_buffer(self): if self.buffer[0] == 0: self.pair = self.buffer[1:21] elif len(self.pair) == 20 and self.buffer[0] == 2: self.pair += self.buffer[1:21] if len(self.pair) == 40 and self.pair != self.last_pair: rolling, fixed = secplus.decode(self.pair) print secplus.pretty(rolling, fixed) self.last_pair = self.pair
def test_pretty_invalid_pin(self): for pin in range(11030, 3**9): rolling = random.randrange(2**32) & 0xfffffffe pad_id = random.randrange(3**7) fixed = pin * (3**10) + pad_id * (3**3) pretty = f"Security+: rolling={rolling} fixed={fixed} (id1=0 id0=0 switch=0 pad_id={pad_id})" pretty_out = secplus.pretty(rolling, fixed) self.assertEqual(pretty, pretty_out)
def test_pretty(self): for pretty, rolling, fixed in zip(self.v1_pretty, self.v1_rolling_list, self.v1_fixed_list): pretty = pretty.lstrip() pretty_out = secplus.pretty(rolling, fixed) self.assertEqual(pretty, pretty_out)