Here's a few ways to do this. One thing to note is that if you're going to use separate compression and encryption tools you should always compress before encryption, since encrypted data is essentially non-compressible.
These examples compress and encrypt a file called
$ gpg -c clear_text #Compress & Encrypt
$ gpg -d clear_text.gpg #Decrypt & Decompress
gpg will compress the input file before encryption by default,
-c means to use symmetric encryption with a password. The output file will be
clear_text.gpg. One benefit of using
gpg is that is uses standard OpenPGP formats, so any encryption software that supports OpenPGP will be able to decrypt it.
$ mcrypt -z clear_text #Compress & Encrypt
$ mdecrypt -z clear_text.gz.nc #Decrypt & Decompress
-z option compresses. By default this outputs a file called
$ bcrypt -r clear_text #Compress & Encrypt
$ bcrypt -r clear_text.bfe #Decrypt & Decompress
bcrypt compresses before encrypting by default, the
-r option is so that the input file isn't deleted in the process. The output file is called
clear_text.bfe by default.
$ cat clear_text | gzip | aespipe > clear_text.gz.aes #Compress & Encrypt
$ cat clear_text.gz.aes | aespipe -d | gunzip > clear_text #Decrypt & Decompress
aespipe is what it sounds like, a program that takes input on stdin and outputs aes encrypted data on stdout. It doesn't support compression, so you can pipe the input through gzip first. Since the output goes to stdout you'll have to redirect it to a file with a name of your own choosing. Probably not the most effective way to do what you're asking but aespipe is a versatile tool so I thought it was worth mentioning.