Re: Compress::Zlib inflateInit help



In our last episode, the evil Dr. Lacto had captured our hero,
Paul Marquess <paul.marquess@xxxxxxxxxxxxxx>, who said:

Do you have any more info on the structure of the data in the socket. For
example, is there any significance toyou reading $number bytes at a time
from the socket?

Data spec, including java sample code (I don't speak java)

The basic structure of the data is:

<blockTime><blockSequence><blockSize><block>...

blockTime = a 64-bit long representing the time of the block in
milliseconds since the epoc.

blockSequence = a 32-bit int representing a sequence number for the
block of data (see "id" parameter above).

blockSize = a 32-bit int representing the size of the compressed block
in bytes.

block = a compressed chunk of data.

You will need to take the compressed block of data and uncompress it
to produce workable raw data. You should be able to use a standard ZLIB
compression library to do this. This functionality is usually found in
your existing development environment. In Java, ZLIB is built into the
VM itself. You need to hand the data block to a java.util.zip.Inflater.

Example:
Inflater decompresser = new Inflater();
decompresser.setInput(compressedBlock, 0, compressedDataLength);
byte[] result = new byte[2048];
int resultLength = decompresser.inflate(result);
decompresser.end();
String message = new String(result, 0, resultLength, "UTF-8");

If you can get it to work by prefixing every $number bytes with "\x78\x01"
it sounds like you are dealing with one or more RFC1951 data streams.

No. It only works if I re-run inflateInit and *then* prefix the
string with \x78\x01

If you want Compress::Zlib to read an RFC1951 stream, add the WindowsBits
parameter like this when you create the inflation object

($inflate,$status) = inflateInit(WindowBits => -MAX_WBITS);

That works well for my first data chunk, after that I get
1
line ->
status -> stream end
2
line ->
status -> stream end

use IO::Uncompress::RawInflate qw(:all)

my $data ;
rawinflate $socket => \$data
or die "Cannot uncompress: $RawInflateError\n";

Again, this works well for my first data chunk, but doesn't read the
cleartext data preceding the second data chunk:

0
line -> 06710003526346TradeNLS USD11221066211JRN
status ->
1

--hymie! http://lactose.homelinux.net/~hymie hymie@xxxxxxxxxxxxxxxxxxxxx
------------------------ Without caffeine for 546 days ------------------------
.



Relevant Pages

  • AidAim CryptoPressStream 2.00
    ... CryptoPressStream is a streaming compression and encryption library. ... in the stream object. ...
    (comp.software.shareware.announce)
  • Using compression with encryption
    ... I am developing an internal compression format. ... encryption as well. ... open cryptographic output stream above this stream ... first with GZipStream and then encrypted with CryptoStream ...
    (microsoft.public.dotnet.framework)
  • Using compression with encryption
    ... I am developing an internal compression format. ... encryption as well. ... open cryptographic output stream above this stream ... first with GZipStream and then encrypted with CryptoStream ...
    (microsoft.public.dotnet.framework)
  • Re: Standard Interface for Data Compression Algorithms
    ... here is a multiplexed stream format, ... "Standard Interface for Data Compression Algorithms". ...
    (comp.compression)
  • [ANN] CryptoPressStream - new streaming compression and encryption library
    ... CryptoPressStream is a streaming compression and ecnryption library. ... It provides transparent access to compressed or encrypted data stored in the stream object. ... - Transparent streaming compression and encryption library with 100 % TStream compatibility. ...
    (borland.public.delphi.thirdpartytools.general)