private-key-qr-backup/bin/create_codes

24 lines
479 B
Bash
Executable File

#!/usr/bin/env bash
set -e
KEY=$1
OUTPUT=${2:-qr.private.pdf}
SINGLE_SIZE=${3:-1024}
gpg2 --export-secret-key "$KEY" | paperkey --output-type raw | base64 | split -b "$SINGLE_SIZE"
index=1
for i in x*; do
qrencode --8bit --level=M -o "qr.$index.png" < "$i"
let index=index+1
done
montage -title "private key for $KEY" -label "%t" -mode concatenate $(find . -name "qr.*.png" | sort -V) "$OUTPUT"
function finish {
rm -f x*
rm -f qr.*.png
}
trap finish EXIT