First of all an important technical detail. You say that
you want to encrypt and then compress. Unfortunately in
order to compress you need to find and take advantage of
patterns in the data - and encryption tries to make sure
there are no understandable patterns. Therefore you need
to compress and then encrypt.
For a compression library I would use
Compress::ZLib. If you want to stream you will
need to use deflateInit/deflate/flush for compression and
inflateInit/inflate for decompression. (Read the
documentation for details - I don't have time at the
moment to hack up some pseudocode.)
One warning. You need to think through what your
buffering strategy is. Compression and encryption work
best when they get as much data as they want to do a
chunk of work. Streaming data often cares about
latency. The two goals conflict - if a message halfway
fills a compression buffer and you let compression work
like it wants to, the message won't get sent for an
indefinite amount of time.
Two articles that may help you understand the warning.
See Suffering
From Buffering and then
It's
the Latency, Stupid. If you read those and don't follow
my point, just ask.
UPDATE
A random tip which is not quite worth a new post. If you are on Windows, you will need to look at binmode.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.