def _pad(block, n=8):
    """Pads the block to a multiple of n

    Accepts an arbitrary sized block and pads it to be a multiple of n.
    Padding is done using the PKCS5 method, i.e., the block is padded with
    the same byte as the number of bytes to add.

    Args:
        block (bytes): The block to pad, may be arbitrary large.
        n (int): The resulting bytes object will be padded to a multiple of this number

    Returns:
        bytes: a bytes object created from the input string

    """

    pad_len = n - (len(block) % n)
    block += bytes([pad_len] * pad_len)
    return block