• Fedegenerate@lemmynsfw.com
    link
    fedilink
    English
    arrow-up
    39
    arrow-down
    1
    ·
    2 years ago

    Anyone willing to drop some learning on a lay person? Is encrypted data less compressable because it lacks the patterns compression relies on?

    Or, is it less secure to encrypt first because smart people things? I know enough about cryptography to know I know fuck all about cryptography.

    • Dogeek@sh.itjust.works
      link
      fedilink
      arrow-up
      43
      ·
      2 years ago

      ELI5 : Take the string AAAA.

      A simple Cypher would be to change the letters to the next one in the alphabet and offset by 1 for each letter, the message would encrypt to ABCD.

      If you try to compress that, well you can’t do it, otherwise you lose required information.

      If you were to compress AAAA first, you could represent it as the string 4A. You can then encrypt that to 5B.

      Encrypting is about adding entropy to a message. Compressing is about finding common groups and represent them differently so that the size is lower. Compressing an encrypted message is basically useless because you added so much entropy to the message that there are no more recognizable patterns to apply compression to.

    • marcos@lemmy.world
      link
      fedilink
      arrow-up
      36
      ·
      2 years ago

      It’s not compressible at all. You will end-up with a file that is larger than the original.

      Whether compressing before you encrypt leaks information, or not compressing is what leaks, or it’s irrelevant is complicated to decide and depends on the details of what you are doing. But encrypting and then compressing is a bit worse than useless, and always a mistake.

        • marcos@lemmy.world
          link
          fedilink
          arrow-up
          4
          ·
          2 years ago

          Well, encryption tends to be either a very fast operation or something with a slow stage that doesn’t depend on the size of your data. So although this is technically true, it’s also not relevant.

    • argv_minus_one@beehaw.orgBanned
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      2 years ago

      It’s less secure to compress and encrypt at all, unless the compresstext is static (such as a pre-made image or video). See BREACH.

    • odium@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      2 years ago

      Also a lay person. Maybe it’s because of the time complexity. Let’s say you have data of size 10 (any unit) which becomes size 8 after compression.

      If you encrypt first: Encrypt size 10 of data -> Conpress size 10 of data

      If you compress first: Compress size 10 of data -> Encrypt size 8 of data

      So second way is faster as the compression still takes the same size of input but the encryption takes a smaller input.