Skip to content

Instantly share code, notes, and snippets.

@tevino
Last active April 7, 2019 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tevino/73a8c50047e4e84ecea557bcca31e1ef to your computer and use it in GitHub Desktop.
Save tevino/73a8c50047e4e84ecea557bcca31e1ef to your computer and use it in GitHub Desktop.
A script to split long(e.g. 4096 bits) private keys into qr codes so you could print on a paper.
#!/bin/sh
# Q&As
#
# Q: Why not use [paperkey][paperkey]?
# A: It brings much more complexity and dependencies, and I don't have time to check the implementation for security.
#
# Q: Why not OCR?
# A: I didn't find an open-source ocr software that works for normal photos.
# even though I used [OCR-A][OCR-A] for printing and [ScannerPro][ScannerPro] for image processing.
#
# [paperkey]: http://www.jabberwocky.com/software/paperkey
# [OCR-A]: https://en.wikipedia.org/wiki/OCR-A
# [ScannerPro]: https://readdle.com/scannerpro
# Dependencies
# - split
# - qrencode https://fukuchi.org/works/qrencode/index.html.en
dump() {
out_dir=$1
if ! mkdir -p "$out_dir"; then
exit 1
fi
split -a 1 -b 2600 - "$out_dir/key_part."
for part in "$out_dir/"key_part.*; do
#dmtxwrite -o "$part.png" < "$part"
qrencode -o "$part.png" -r "$part"
done
}
main() {
dir=${2-output}
dump "$dir"
echo "Usage: $0 [output-dir] < key-file"
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment