def get_byte_array(integer, signed):
    """Gets the arbitrary-length byte array corresponding to the given integer"""
    bits = integer.bit_length()
    byte_length = (bits + 8 - 1) // 8  # 8 bits per byte
    return int.to_bytes(
        integer, length=byte_length, byteorder='big', signed=signed)