defhack_put(self, num, length): if num == 0: num = 1 for i inrange(length): self.put_bit(((num >> (length - i - 1)) & 1) == 1) data = message.encode('utf-8') data_len = len(data)
version = 1 while version <= len(NUM_BLOCKS) and data_len + 3 > NUM_BLOCKS[version-1]: version += 1 if version > len(NUM_BLOCKS): raise Exception('message too long')
data += b' ' * (NUM_BLOCKS[version-1] - data_len - 3)