mirror of
https://github.com/sunknudsen/privacy-guides.git
synced 2025-02-23 09:13:56 +00:00
Polished encrypted paper backup guide
This commit is contained in:
parent
a2d7276e14
commit
3d5cea224b
@ -136,7 +136,7 @@ qr-backup.sh
|
|||||||
|
|
||||||
### Restore encrypted paper backup
|
### Restore encrypted paper backup
|
||||||
|
|
||||||
> Heads-up: use `--split-words` to split secret into word list.
|
> Heads-up: use `--word-list` to split secret into word list.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
qr-restore.sh
|
qr-restore.sh
|
||||||
|
@ -89,7 +89,7 @@ if [ "$bip39" = true ]; then
|
|||||||
words=($secret)
|
words=($secret)
|
||||||
for word in ${words[@]}; do
|
for word in ${words[@]}; do
|
||||||
if ! exists $word; then
|
if ! exists $word; then
|
||||||
printf "$red%s$normal\n" "Invalid word $bold$word$normal"
|
printf "$red%s $bold%s$normal\n" "Invalid word" "$word"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -102,8 +102,8 @@ encrypted_secret_hash=$(echo -n "$encrypted_secret" | openssl dgst -sha512 | sed
|
|||||||
encrypted_secret_short_hash=$(echo -n "$encrypted_secret_hash" | head -c 8)
|
encrypted_secret_short_hash=$(echo -n "$encrypted_secret_hash" | head -c 8)
|
||||||
|
|
||||||
printf "%s\n" "$encrypted_secret"
|
printf "%s\n" "$encrypted_secret"
|
||||||
printf "SHA512 hash: $bold%s$normal\n" "$encrypted_secret_hash"
|
printf "%s: $bold%s$normal\n" "SHA512 hash" "$encrypted_secret_hash"
|
||||||
printf "SHA512 short hash: $bold%s$normal\n" "$encrypted_secret_short_hash"
|
printf "%s: $bold%s$normal\n" "SHA512 short hash" "$encrypted_secret_short_hash"
|
||||||
|
|
||||||
echo -n "$encrypted_secret" | qr --error-correction=H > "$tmp/secret.png"
|
echo -n "$encrypted_secret" | qr --error-correction=H > "$tmp/secret.png"
|
||||||
|
|
||||||
|
Binary file not shown.
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
tput reset
|
||||||
|
|
||||||
printf "%s\n" "Restoring…"
|
printf "%s\n" "Restoring…"
|
||||||
. qr-restore.sh
|
. qr-restore.sh
|
||||||
|
|
||||||
|
Binary file not shown.
@ -6,8 +6,8 @@ positional=()
|
|||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
argument="$1"
|
argument="$1"
|
||||||
case $argument in
|
case $argument in
|
||||||
--split-words)
|
--word-list)
|
||||||
split_words=true
|
word_list=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@ -23,6 +23,8 @@ bold=$(tput bold)
|
|||||||
red=$(tput setaf 1)
|
red=$(tput setaf 1)
|
||||||
normal=$(tput sgr0)
|
normal=$(tput sgr0)
|
||||||
|
|
||||||
|
tput reset
|
||||||
|
|
||||||
printf "%s\n" "Scan QR code…"
|
printf "%s\n" "Scan QR code…"
|
||||||
|
|
||||||
data=""
|
data=""
|
||||||
@ -45,8 +47,8 @@ encrypted_secret_hash=$(echo -n "$encrypted_secret" | openssl dgst -sha512 | sed
|
|||||||
encrypted_secret_short_hash=$(echo -n "$encrypted_secret_hash" | head -c 8)
|
encrypted_secret_short_hash=$(echo -n "$encrypted_secret_hash" | head -c 8)
|
||||||
|
|
||||||
printf "%s\n" "$encrypted_secret"
|
printf "%s\n" "$encrypted_secret"
|
||||||
printf "SHA512 hash: $bold%s$normal\n" "$encrypted_secret_hash"
|
printf "%s: $bold%s$normal\n" "SHA512 hash" "$encrypted_secret_hash"
|
||||||
printf "SHA512 short hash: $bold%s$normal\n" "$encrypted_secret_short_hash"
|
printf "%s: $bold%s$normal\n" "SHA512 short hash" "$encrypted_secret_short_hash"
|
||||||
|
|
||||||
printf "$bold$red%s$normal\n" "Show secret? (y or n)? "
|
printf "$bold$red%s$normal\n" "Show secret? (y or n)? "
|
||||||
|
|
||||||
@ -54,12 +56,12 @@ read -r answer
|
|||||||
if [ "$answer" = "y" ]; then
|
if [ "$answer" = "y" ]; then
|
||||||
secret=$(echo -e "$encrypted_secret" | gpg --decrypt)
|
secret=$(echo -e "$encrypted_secret" | gpg --decrypt)
|
||||||
gpg-connect-agent reloadagent /bye > /dev/null 2>&1
|
gpg-connect-agent reloadagent /bye > /dev/null 2>&1
|
||||||
if [ "$split_words" = true ]; then
|
if [ "$word_list" = true ]; then
|
||||||
printf "%s" "Secret: "
|
printf "%s" "Secret: "
|
||||||
array=($secret)
|
array=($secret)
|
||||||
for i in ${!array[@]}; do
|
for i in ${!array[@]}; do
|
||||||
position=$(($i + 1))
|
position=$(($i + 1))
|
||||||
printf "%s" "$position.$bold${array[$i]}$normal "
|
printf "%d. $bold%s$normal " "$position" "${array[$i]}"
|
||||||
done
|
done
|
||||||
printf "\n"
|
printf "\n"
|
||||||
else
|
else
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user