def pkcs7_unpad(data: bytes, blocksize: int = 16) -> bytes:
    """
    Validates and removes PKCS7 padding
    :param data: The padded data
    :param blocksize: The blocksize to validate padding based on
    :return: data with padding removed
    """
    if len(data) == 0 or len(data) % blocksize != 0:
        raise ValueError("Invalid Padding")
    elif not 0x00 < data[-1] <= blocksize:
        raise ValueError("Invalid Padding")
    elif any(data[-1-i] != data[-1] for i in range(data[-1])):
        raise ValueError("Invalid Padding")
    else:
        return data[:-data[-1]]