Skip to content

Instantly share code, notes, and snippets.

@GrantTrebbin GrantTrebbin/QRBackup.sh
Last active Aug 7, 2019

Embed
What would you like to do?
How to encode and decode a file backed up as a series of printed QR codes
# How to encode and decode a file backed up as a series of printed QR codes
# Install the required tools
sudo apt-get update
sudo apt-get install zbar-tools imagemagick qrencode
################################################################################
# Convert the file to a base 64 encoded format. Probably not needed as QR codes
# are capable of encoding 8-bit binary data. I just do it to be safe.
base64 keyfile.kdb > keyfile.64
# Split this file into a series of smaller files that can be converted to QR
# codes. Use your judgement.
split -n 6 keyfile.64 Passwords_kdb_64
# Encode each portion of the split file as a QR code. The -l H option gives
# maximum error correction capability by increasing redundancy in the code.
for file in ./Passwords_kdb_64*; do qrencode -l H -o $file.png < $file; done
# Combine 6 QR codes into one image containing 3 rows of 2 codes with
# filenames under each code.
montage -label '%f' *.png -geometry '1x1<' -tile 2x3 Passwords_kdb_64.png
################################################################################
# Scan each of the QR codes in order and redirect the output to a file. Each
# code is on a new line with a header identifying the type of code scanned. The
# new lines and headers need to be removed. This was done manually.
zbarcam > keyfile.64
# The the base 64 code that has just been read and convert it back to the
# original binary file.
base64 -d keyfile.64 > keyfile.kdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.