commit 61dec59f3e22027b389e2bef197c87a4a4ab8b68 Author: Sebastian Hugentobler Date: Thu Jul 19 12:30:54 2018 +0200 Initial commit diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d1f040a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 4 + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f0eba74 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*~ +.DS_Store +*.swp +target diff --git a/README b/README new file mode 100644 index 0000000..65d9249 --- /dev/null +++ b/README @@ -0,0 +1,10 @@ +Two scripts to create qr codes from a private key and to restore them. + +Use "create_codes" to create a pdf "qr.private.pdf" with arranged qrcodes (it +takes the key id as an input). + +When restoring, scan the qr codes in the order of their numbers, put the parts +into numbered txt files and run the "restore_key" script with the first arg being +the path to the public key and the second one the path to the directory with the +txt files. + diff --git a/bin/create_codes b/bin/create_codes new file mode 100755 index 0000000..79aad5d --- /dev/null +++ b/bin/create_codes @@ -0,0 +1,23 @@ +#!/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 diff --git a/bin/restore_key b/bin/restore_key new file mode 100755 index 0000000..544d98c --- /dev/null +++ b/bin/restore_key @@ -0,0 +1,7 @@ +#!/usr/bin/env sh +set -e + +PUB_KEY=$1 +INPUT_DIR=${2:-.} + +cat "$INPUT_DIR"/*.txt | base64 -D | paperkey --pubring "$PUB_KEY" --input-type raw --output private.key