Stephen,

Based on the code in test.cpp for GzipFile and GunzipFile, I have always
used the following, and it should work for you:

// Gzip contents of plaintext into gzip_text;
StringSource(plaintext, true, new Gzip(new StringSink(gzip_text))); 

// Ungzip contents of gzip_text into unzip_text;
StringSource(gzip_text, true, new Gunzip(new StringSink(unzip_text))); 

Maybe I am missing something in your requirements?  (I have been pretty much
following your whole thread.)

You can also string these together, so if you want to gzip then B64 encode,
you could:

StringSource(plaintext, true, new Gzip(new Base64Encoder(new
StringSink(b64_text)))); 

And then to undo it back to plaintext, you do:

StringSource(b64_text, true, new Base64Decoder(new Gunzip(new
StringSink(unb64_text)))); 

Hope this helps,

Scott Barnhart


-----Original Message-----
From: Stephen torri [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 18, 2003 4:38 PM
To: cryptopp
Subject: Gzip & Gunzip code: Correct or rubbish

I decided to work on get my encrypt and decrypt methods in stages. The
first stage is to get the plain text string compressed and decompressed
correctly.

Gcc:3.2.3
Crypto:5.1

Compress:

string gzip_text;
Gzip aes_compressor2 (new StringSink (gzip_text));
StringStore(plaintext).TransferTo(aes_compressor2);

string unzip_text;
Gunzip aes_decompressor2 (new StringSink (unzip_text));
StringStore(gzip_text).TransferTo(aes_decompressor2);

I got this from searching the archive of the mailing list. Shame we do
not have a directory of example programs. Is this right? So far I
believe it does not because what I get in 'unzip_text' is rubbish.

Plaintext char:  B  o  o     H  o  o     I     a  m     s  o     s  c 
a  r  e  d
Plaintext hex:  0x42  0x6f  0x6f  0x20  0x48  0x6f  0x6f  0x20  0x49 
0x20  0x61  0x6d  0x20  0x73  0x6f  0x20  0x73  0x63  0x61  0x72  0x65 
0x64

<OUTPUT: Compress plain text>
Compressed text2:  0x1f  0xffffff8b  0x8  0  0  0  0  0  0  0

<OUTPUT: Decompressed plain text>
Decompressed text2:

Stephen

Reply via email to