Freigeben über


Why can I not compress AND encrypt a folder in Windows?

Just a random bit of knowledge to share here :)

If you open the Advanced Attributes of a folder (right-click on it, choose properties, then click Advanced...), you have the option at the bottom of the window to either compress the contents to save disk space, or encrypt the contents to secure data.

Judging by the check-box options instead of radio buttons, you might think that you can select both options, but you cannot.  Bad UI aside, why is this?

image

According to Wikipedia's article on File Compression (https://en.wikipedia.org/wiki/File_compression):

Lossless compression algorithms usually exploit statistical redundancy in such a way as to represent the sender's data more concisely with fewer errors. Lossless compression is possible because most real-world data has statistical redundancy. For example, in English text, the letter 'e' is much more common than the letter 'z', and the probability that the letter 'q' will be followed by the letter 'z' is very small.

<snip>

However, lossless data compression algorithms will always fail to compress some files; indeed, any compression algorithm will necessarily fail to compress any data containing no discernible patterns. Attempts to compress data that has been compressed already will therefore usually result in an expansion, as will attempts to compress encrypted data.

So... compression algorithms work their magic by finding redundant data, and replacing the redundancy with a smaller bit of data that can be expanded out to represent that redundant data (yes, the word "redundant" was quite redundant in the previous sentence).  However, data that has been encrypted by a good encryption algorithm should be indistinguishable from random data. 

If there are redundant patterns in the encrypted file, the encrypted data may be subject to cryptanalysis techniques such as Frequency Analysis.  The Encrypting File System (EFS) within Windows uses FIPS 140-evaluated Microsoft Cryptographic Service Providers,so your encrypted data is safe.  Attempts to compress this encrypted data would actually cause the file size to INCREASE.  Good times!

Read more about the Encrypting File System and associated best practices here and here.

Comments

  • Anonymous
    January 01, 2003
    I was going to say what Mike just said...

  • Anonymous
    January 01, 2003
    I was going to say what Mike just said...

  • Anonymous
    January 01, 2003
    You just need a Folder Protector. I'd rate KaKa Folder Protector, which can easily encrypt any folder for protection and completely compatible with Vista. Free to download http://www.sharewarecheap.com/KaKa-Folder-Protector_software_3039.html

  • Anonymous
    September 25, 2012
    I can see the argument for not being able to compress after encrypting, but is there any particular technical reason why I file couldn't be compressed, and THEN encrypted?  The file would, of course, need to be uncompressed after being decrypted, but I wouldn't think that should be terribly difficult...

  • Anonymous
    July 02, 2014
    So was I. ;-)

  • Anonymous
    July 02, 2014
    Actually you can. You just can't do it using Windows' native compression. However, an encrypted folder can contain files compressed using a product such as Winzip or 7-Zip.

  • Anonymous
    July 02, 2014
    http://www.tomsitpro.com/articles/windows-8.1-the-missing-manual-book-excerpt,2-723-3.html">Encrypting Files & Folders - Windows 8.1: The Missing Manual