public static void dumpData(String text, byte[] data, int length) {
        System.out.println(text);

        for (int i=0; i<length; i++) {
            if (i%32 == 0)
                System.out.print(String.format(" %14X  ", i));
            else if (i%4 == 0)
                System.out.print(" ");

            System.out.print(String.format("%02X", data[i]));

            if (i%32 == 31)
                System.out.println();
        }

        if (length%32 != 0)
            System.out.println();
    }