def check_sum(data):
    """
    Calculates a checksum as the modulo 256 sum then bit inverted (1's complement).

    `data` is an iterable list of bytes or ints < 256
    """
    return (sum(data) % 256) ^ 0xff