Generating QR code of very big file?

Your error message already gives a hint as to what's wrong!

Your one-liner is providing the actual file content as filename to the qrencode program. Hence the error message.

Try qrencode -o test.png -t png < private.key.

You should take a look at shell input-output redirection. For example, I/O Redirection.

I see that you too have found your way to the developers GitHub repository of qrencode :) There is an explanation why a 4096-bit key cannot be encoded as a QR code:

qrencode is encoding your private GPG key as 8 bit (binary|utf-8), because the key is not pure alphanumeric. It contains special character. the alphanumeric mode only supports those special character .(%*+-./:). So the maximum GPG key can only be 2953 char long.


From https://github.com/fukuchi/libqrencode/issues/31


The key could not be encoded as a single QR code. But two (or more) could work.

  • Export your key (as before):

    gpg --export-secret-keys --armor > private.key
    
  • Generate files of a maximun size of 2500 byte:

    split -C 2500 private.key splitkey-
    
  • Convert each to one QR file (same name with extension .qr)

    for file in splitkey-??; do
        <"$file" qrencode -s 3 -d 150 -o "$file".qr
    done
    

When it is needed to recover the key. You can scan each QR code which will each produce an string. Just concatenate each string in sequence of the filenames. Lets assume that the result key is stored in the file newkey.

And you may test that the internal CRC-24 of the key checks out.

 gpg --dearmor newkey >/dev/null

If there is no error message, the key file has been reconstructed correctly.


I just found out that this is not possible.

% wc -c ~/private.key
6709 /home/toogley/private.key

(-c counts characters.)

to cite from wikipedia:

max characters for alphanumerical characters: 4,296.

Tags:

Bash

Qr Code

Gpg