public static function bytesToDump($bytes, $max = 0)
    {
        $s = strlen($bytes);

        if ($max > 0) {
            $s = min($max, $s);
        }
        $line = 24;

        for ($i = 0; $i < $s; $i ++) {
            printf('%02X ', ord($bytes{$i}));

            if (($i + 1) % $line == 0) {
                print("\n");
            }
        }
        print("\n");
    }