public static byte[] permutFunc(byte[] input, int[] table) {
        int nrBytes = (table.length - 1) / 8 + 1;
        byte[] out = new byte[nrBytes];
        for (int i = 0; i < table.length; i++) {
            int val = getBitInt(input, table[i] - 1);
            setBit(out, i, val);
        }
        return out;
    }