예제 #1
0
 def reveal(self, order_num=0, bad_bits_num=1):
     size = list()
     bits_iterator = iter(self._iter_hidden_bits(order_num, bad_bits_num))
     for bit in bits_iterator:
         size.append(bit)
         if len(size) == 32:
             break
     size = unpack(">L", byte_tools.to_bytes(size))[0] * 8
     current_pos = 0
     result = list()
     for bit in bits_iterator:
         result.append(bit)
         current_pos += 1
         if len(result) == 8:
             yield byte_tools.to_bytes(result)[0]
             result.clear()
         if current_pos == size:
             break
     if result:
         yield byte_tools.to_bytes(result)[0]
예제 #2
0
 def test_to_bytes(self):
     first = b'\xff\x01'
     b = bytes(byte_tools.to_bytes(byte_tools.to_bits(first)))
     self.assertEqual(first, b)