def store(key, message, in_path, out_path): epub = Epub() epub.expand(in_path) space = Space(epub) binary_message = ''.join([format(ord(x), '0'+str(CHAR_BIT_SIZE)+'b') for x in message]) message_size = format(len(binary_message), 'b') header_size = format(len(message_size), '0'+str(HEADER_BIT_SIZE)+'b') bits_to_write = header_size + message_size + binary_message if (len(space)) < len(bits_to_write): print 'Error, not enough space on the epub file' line_order = LineOrder(key, len(space)) add_noise(space) for bit in bits_to_write: space[line_order.next()] = (bit == '1') space.commit() epub.contract(out_path)