Search code examples
stringencryptioncompressionqr-codepgp

How to shorten the length of a PGP message


I need to generate a QR code from a PGP message. The problem is the code is coming out way too big (about 3 x 3 inches).

How can I shorten the length of the PGP message to generate the QR code?


Solution

  • The size of an OpenPGP message depends on:

    • The message itself (compressability, length)
    • The symmetric encryption algorithm (mainly because the cipher block needs to be stored)
    • ASCII armored output is much larger than the binary version, don't armor if it works without
    • As @Duncan already said, signing needs further space

    Try different symmetric algorithms, and try whether forcing GnuPG not to compress actually makes the message smaller (as the compression headers also need a little bit of space).

    To look into an OpenPGP message and see what's contained, use gpg --list-packets.

    Furthermore, you can try to tweak the QR code (redundancy), or put an URL into the QR code which links to the message itself.