• dan@lemm.ee
    link
    fedilink
    English
    arrow-up
    32
    ·
    edit-2
    1 year ago

    Lossless compression algorithms aren’t magical, they can’t make everything smaller (otherwise it would be possible to have two different bits of input data that compress to the same output). So they all make some data bigger and some data smaller, the trick is that the stuff they make smaller happens to match common patterns. Given truly random data, basically every lossless compression algorithm will make the data larger.

    A good encryption algorithm will output data that’s effectively indistinguishable from randomness. It’s not the only consideration, but often the more random the output looks, the better the algorithm.

    Put those two facts together and it’s pretty easy to see why you should compress first then encrypt.