Skip to content

Instantly share code, notes, and snippets.

@projectivemotion
Forked from joostrijneveld/gpg2qrcodes.sh
Last active September 9, 2021 04:47
Show Gist options
  • Select an option

  • Save projectivemotion/16236138fd62db1eaa10b06019b359ea to your computer and use it in GitHub Desktop.

Select an option

Save projectivemotion/16236138fd62db1eaa10b06019b359ea to your computer and use it in GitHub Desktop.

Revisions

  1. projectivemotion revised this gist Sep 24, 2018. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions gpg2qrcodes.sh
    Original file line number Diff line number Diff line change
    @@ -22,6 +22,9 @@ cat <<EOF >decryptmyfiles.sh
    gpg --pinentry-mode loopback --decrypt-files *.gpg
    EOF

    cat <<EOF >encryptmyfiles.sh
    #!/bin/bash
    gpg --pinentry-mode loopback --encrypt-files \$@
    EOF


    chmod +x importmykey.sh decryptmyfiles.sh
    chmod +x importmykey.sh decryptmyfiles.sh encryptmyfiles.sh
  2. projectivemotion revised this gist Sep 24, 2018. 1 changed file with 20 additions and 13 deletions.
    33 changes: 20 additions & 13 deletions gpg2qrcodes.sh
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,27 @@
    # Heavily depends on:
    # libqrencode (fukuchi.org/works/qrencode/)
    # paperkey (jabberwocky.com/software/paperkey/)
    # zbar (zbar.sourceforge.net)
    #!/bin/bash

    # Producing the QR codes:
    # Split over 4 codes to ensure the data per image is not too large.
    type paperkey || pacman -S paperkey
    gpg --export-secret-key | paperkey --output-type raw | base64 > temp
    split temp -n 4 IMG
    for f in IMG*; do cat $f | qrencode -o $f.png; rm -vf $f; done
    #1. export gpg private key as ascii
    #2. split ascii into 4 qr code images
    #3. generate bash script for importing bash images
    #4. generate bash script for decrypting files.

    rm -fv temp
    gpg --export-secret-key --armor | split -C 1000 - IMG
    for f in IMG*; do cat $f | qrencode -o $f.png; rm -vf $f; done

    # Importing the QR codes:
    # Note that, when making scans or photographs, you do not produce large images.
    # If zbar does not recognise your QR code, try downscaling the image.
    # for f in IMG*.png; do zbarimg --raw $f | head -c -1 > $f.out ; done
    # cat *.out | base64 -d | paperkey --pubring ~/.gnupg/pubring.gpg | gpg --import
    cat <<EOF >importmykey.sh
    #!/bin/bash
    touch mykey.asc
    for f in IMG*.png; do zbarimg --raw \$f | head -c -1 ; done | gpg --pinentry-mode loopback --import
    EOF

    cat <<EOF >decryptmyfiles.sh
    #!/bin/bash
    gpg --pinentry-mode loopback --decrypt-files *.gpg
    EOF



    chmod +x importmykey.sh decryptmyfiles.sh
  3. projectivemotion revised this gist Sep 24, 2018. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion gpg2qrcodes.sh
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,9 @@
    type paperkey || pacman -S paperkey
    gpg --export-secret-key | paperkey --output-type raw | base64 > temp
    split temp -n 4 IMG
    for f in IMG*; do cat $f | qrencode -o $f.png; done
    for f in IMG*; do cat $f | qrencode -o $f.png; rm -vf $f; done

    rm -fv temp

    # Importing the QR codes:
    # Note that, when making scans or photographs, you do not produce large images.
  4. projectivemotion revised this gist Sep 24, 2018. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions gpg2qrcodes.sh
    Original file line number Diff line number Diff line change
    @@ -5,13 +5,14 @@

    # Producing the QR codes:
    # Split over 4 codes to ensure the data per image is not too large.
    gpg --export-secret-key KEYIDGOESHERE | paperkey --output-type raw | base64 > temp
    type paperkey || pacman -S paperkey
    gpg --export-secret-key | paperkey --output-type raw | base64 > temp
    split temp -n 4 IMG
    for f in IMG*; do cat $f | qrencode -o $f.png; done

    # Importing the QR codes:
    # Note that, when making scans or photographs, you do not produce large images.
    # If zbar does not recognise your QR code, try downscaling the image.
    for f in IMG*.png; do zbarimg --raw $f | head -c -1 > $f.out ; done
    cat *.out | base64 -d | paperkey --pubring ~/.gnupg/pubring.gpg | gpg --import
    # for f in IMG*.png; do zbarimg --raw $f | head -c -1 > $f.out ; done
    # cat *.out | base64 -d | paperkey --pubring ~/.gnupg/pubring.gpg | gpg --import

  5. @joostrijneveld joostrijneveld created this gist May 20, 2014.
    17 changes: 17 additions & 0 deletions gpg2qrcodes.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    # Heavily depends on:
    # libqrencode (fukuchi.org/works/qrencode/)
    # paperkey (jabberwocky.com/software/paperkey/)
    # zbar (zbar.sourceforge.net)

    # Producing the QR codes:
    # Split over 4 codes to ensure the data per image is not too large.
    gpg --export-secret-key KEYIDGOESHERE | paperkey --output-type raw | base64 > temp
    split temp -n 4 IMG
    for f in IMG*; do cat $f | qrencode -o $f.png; done

    # Importing the QR codes:
    # Note that, when making scans or photographs, you do not produce large images.
    # If zbar does not recognise your QR code, try downscaling the image.
    for f in IMG*.png; do zbarimg --raw $f | head -c -1 > $f.out ; done
    cat *.out | base64 -d | paperkey --pubring ~/.gnupg/pubring.gpg | gpg --import