zip, gzip and Deflate

B

Bhanu

Hello everyone,

i have a little concern about which class to use for compression
of the data, The data is some binary encrypted data. java.util.zip
provides three options
Zip
Gzip
Deflator class,

So which one i should use for compression to get better,
1) Compression ?
2) Time ?


Any suggestion will help me a lot. :)


Thanks,
Bhanu
 
U

usenetuser

Hello everyone,

i have a little concern about which class to use for compression
of the data, The data is some binary encrypted data. java.util.zip
provides three options
Zip
Gzip
Deflator class,

So which one i should use for compression to get better,
1) Compression ?
2) Time ?

Any suggestion will help me a lot. :)

Thanks,
Bhanu

Why don't you perform some tests and see which is better *for your and
your data*.
 
B

Bhanu

Why don't you perform some tests and see which is better *for your and
your data*.

Yes I am doing that but I am using dummy data as the whole application
is not ready yet and I dont have original inputs. I felt may be
someone has already faced this issue. :)
 
I

Ian Wilson

Bhanu said:
>
Yes I am doing that but I am using dummy data as the whole
application is not ready yet and I dont have original inputs. I felt
may be someone has already faced this issue. :)

The point of encryption is that there should be no pattern in the
cyphertext, since you say "binary" this implied all possible values of
each byte can be used. These two features should make it incompressible.
 
C

Chris Uppal

Bhanu said:
i have a little concern about which class to use for compression
of the data, The data is some binary encrypted data. java.util.zip
provides three options
Zip
Gzip
Deflator class,

So which one i should use for compression to get better,
1) Compression ?
2) Time ?

If you are just compressing a single stream of data, then there's nothing to be
gained by using ZIP format -- that is designed specifically for packing
/several/ files (compressed) into one larger archive file.

The other two formats are not essentially different. All three formats use the
same compression algorithm with the same parameters. The /only/ difference
between "deflate" and "gzip" is that the two formats have different
header/trailer information around the (identical) compressed data. "deflate"
puts slightly less (I think it's 12 bytes less), but uses a weaker checksum.
Also the "gzip" format can easily be read by external applications such as the
"gzip" command-line utility, which is universal on Unix-alike platforms and
widely available for Windows.

-- chris
 
C

Chris Uppal

The point of encryption is that there should be no pattern in the
cyphertext, since you say "binary" this implied all possible values of
each byte can be used. These two features should make it incompressible.

I missed that point in my own reply to this. Ian is correct -- there is no
point in trying to compress stuff that has been encrypted[*].

If you need to reduce the sizes then it's best to compress the data before
encryption (which is also better for security, provided you remove the standard
header/trailer from the compressed data).

-- chris


[*] Technically encrypted data /can/ be highly redundant, and thus highly
compressible -- e.g. just double-up every encrypted byte ;-) But, of course,
no sensible encryption scheme does produce such trivially redundant output.
 
R

rossum

Hello everyone,

i have a little concern about which class to use for compression
of the data, The data is some binary encrypted data. java.util.zip
provides three options
Zip
Gzip
Deflator class,

So which one i should use for compression to get better,
1) Compression ?
2) Time ?


Any suggestion will help me a lot. :)


Thanks,
Bhanu
As has been pointed out, it is probably pointless to compress
encrypted data. The whole point of encryption is to increase the
entropy of the cyphertext, which makes it less compressible.

If you wish to reduce the size of your encrypted files then you should
try compressing the plaintext first and then encrypting the compressed
file.

Two warnings:

1 Most compression formats have standard headers etc. These may
increase the amount of structure in your file and hence make it easier
to decrypt. Whether this is a problem depends on how much structure
there is in your uncompressed plaintext and who you are trying to
conceal it from.

2 Generaly avoid the encryption options built into compression
programs. They are fine for stopping casual snooping but are not as
secure as a properly implemented strong encryption algorithm.

rossum
 
B

Bhanu

As has been pointed out, it is probably pointless to compress
encrypted data. The whole point of encryption is to increase the
entropy of the cyphertext, which makes it less compressible.

If you wish to reduce the size of your encrypted files then you should
try compressing the plaintext first and then encrypting the compressed
file.

Two warnings:

1 Most compression formats have standard headers etc. These may
increase the amount of structure in your file and hence make it easier
to decrypt. Whether this is a problem depends on how much structure
there is in your uncompressed plaintext and who you are trying to
conceal it from.

2 Generaly avoid the encryption options built into compression
programs. They are fine for stopping casual snooping but are not as
secure as a properly implemented strong encryption algorithm.

rossum

Thanks all of you for helping me out. I was really doing an stupid
thing.
Yeah you should compress first and then encrypt seems logical and
correct.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top