http://www.perlmonks.org?node_id=11123177

Kroning has asked for the wisdom of the Perl Monks concerning the following question:

Hi!

I have some packet from app that looks like "ec bd ... 00 00 ff ff" which I am trying to decode.

From what I have found, it looks like "00 00 ff ff" is a Z_SYNC_FLUSH of deflate (zlib).

I tried to reproduce it on Compress::Raw::Zlib, Compress::Zlib and some others. But the ending pattern was "00 ff 00 ff". Am I missing something?

#!/usr/local/bin/perl use Compress::Zlib ; my $x = deflateInit() or die "Cannot create a deflation stream\n" ; ($output, $status) = $x->deflate('text') ; ($output, $status) = $x->flush(Z_SYNC_FLUSH) ; $output =~ s/(.)/sprintf '%04x', ord $1/seg; print "output=$output\n";
output=002a004900ad0028000100000000000000ff00ff00000000000000ff00ff