5
5
6
6
# If this software does not suit you, here are some alternative pieces of
7
7
# software that are very similar:
8
- # age <https://github.com/FiloSottile/age
9
- # rage <https://github.com/str4d/rage
8
+ # scrypt https://www.tarsnap.com/scrypt.html
9
+ # age https://github.com/FiloSottile/age
10
+ # rage https://github.com/str4d/rage
10
11
# https://github.com/SixArm/gpg-encrypt
11
12
# https://github.com/SixArm/gpg-decrypt
12
13
# https://github.com/SixArm/openssl-encrypt
@@ -48,7 +49,9 @@ UMASK_READONLY="0377" # created files (will be r--)
48
49
# SHA_HASH_ITERATIONS: -iter 100,000,000 roughly 1 min on basic average 2020 CPU, tested
49
50
# SHA_HASH_ITERATIONS: -iter 1,000,000,000 roughly 10 min on basic average 2020 CPU, tested
50
51
# to calculate time run: openssl speed sha512 .... and look at the 256 block size
51
- SHA_HASH_ITERATIONS_RECOMMENDED=100000000 # 100M
52
+ # We don't use a round number like 100000000 just in case there is or
53
+ # will be a rainbow table for round numbers of hahes like 100000000.
54
+ SHA_HASH_ITERATIONS_RECOMMENDED=100000017 # 100M
52
55
SHA_HASH_ITERATIONS=$SHA_HASH_ITERATIONS_RECOMMENDED # 100M
53
56
# SHA_HASH_ITERATIONS=100000 # 100K # for testing only
54
57
HASHING_TIME_IN_SEC=$( expr $SHA_HASH_ITERATIONS / 1666666) # estimate for moderate CPU in 2020
@@ -62,7 +65,7 @@ PASSPHRASE_FILE_CHACHA_OPTION="-pass file:$PASSPHRASE_FILE_CHACHA_FILE"
62
65
63
66
# usage: outputs to stdout the --help usage message.
64
67
usage () {
65
- echo " ${0##*/ } : Version: v2020-09-30 "
68
+ echo " ${0##*/ } : Version: v2020-11-02 "
66
69
echo " ${0##*/ } : Usage: ${0##*/ } [--help] [--encrypt|--decrypt] files"
67
70
echo " ${0##*/ } : e.g. ${0##*/ } file1.txt file2.jpg # encrypt 2 files"
68
71
echo " ${0##*/ } : e.g. ${0##*/ } # read from stdin, encrypt text from stdin input"
@@ -81,11 +84,11 @@ usage() {
81
84
echo " ${0##*/ } : If no file is provided as command line argument, script will read "
82
85
echo " ${0##*/ } : plain-text from std input."
83
86
echo " ${0##*/ } : "
84
- echo " ${0##*/ } : If a file named \" passphrase-file-chacha20 \" exists in the local"
87
+ echo " ${0##*/ } : If a file named \" $PASSPHRASE_FILE_CHACHA_FILE \" exists in the local"
85
88
echo " ${0##*/ } : directory, then it will be used as passphrase source instead of stdin"
86
89
echo " ${0##*/ } : for the Chacha20-round (first round) of encryption."
87
90
echo " ${0##*/ } : "
88
- echo " ${0##*/ } : If a file named \" passphrase-file-aes \" exists in the local"
91
+ echo " ${0##*/ } : If a file named \" $PASSPHRASE_FILE_AES_FILE \" exists in the local"
89
92
echo " ${0##*/ } : directory, then it will be used as passphrase source instead of stdin"
90
93
echo " ${0##*/ } : for the AES-round (second round) of encryption."
91
94
echo " ${0##*/ } : "
@@ -97,9 +100,10 @@ usage() {
97
100
echo " ${0##*/ } : Decrypt does the opposite. It recovers the plaintext from the ciphertext."
98
101
echo " ${0##*/ } : TLDR: The whole decryption script in a nutshell does the 3 lines of code from above in the reverse order but with -d instead of -e."
99
102
echo " "
100
- echo " "
101
- echo " Typical encryption process looks similar to this: "
102
- cat << END
103
+ if [ " $DEBUG " == " true" ]; then
104
+ echo " "
105
+ echo " Typical encryption process looks similar to this: "
106
+ cat << END
103
107
$ ./${0##*/ }
104
108
${0##*/ } : Install latest version of "openssl", "shred" and "qrencode"!
105
109
${0##*/ } : It will NOT overwrite files. So, if you run it twice it will give error.
@@ -127,6 +131,7 @@ ${0##*/}: QR codes are in files "ciphertext.png" and "ciphertext.svg"
127
131
${0##*/ } : Meta data is in file "ciphertext.inf"
128
132
${0##*/ } : SUCCESS! Look at ciphertext output in file "ciphertext.enc".
129
133
END
134
+ fi
130
135
} # usage()
131
136
132
137
# takes 1 optional argument, the return value, the exit value
@@ -155,11 +160,13 @@ read-passphrase-files-if-availble() {
155
160
if [ -f " $PASSPHRASE_FILE_CHACHA_FILE " ]; then
156
161
echo " ${0##*/ } : Info: Found file \" $PASSPHRASE_FILE_CHACHA_FILE \" . It will be used as source for the Chacha20 passphrase. You will not be asked for a passphrase for Chacha20 $1 ."
157
162
else
163
+ echo " ${0##*/ } : Info: File \" $PASSPHRASE_FILE_CHACHA_FILE \" not found. It cannot be used as source for the Chacha20 passphrase. You will be asked for a passphrase for Chacha20 $1 ."
158
164
PASSPHRASE_FILE_CHACHA_OPTION=" " # don't use this option
159
165
fi
160
166
if [ -f " $PASSPHRASE_FILE_AES_FILE " ]; then
161
167
echo " ${0##*/ } : Info: Found file \" $PASSPHRASE_FILE_AES_FILE \" . It will be used as source for the AES passphrase. You will not be asked for a passphrase for AES $1 ."
162
168
else
169
+ echo " ${0##*/ } : Info: File \" $PASSPHRASE_FILE_AES_FILE \" not found. It cannot be used as source for the AES passphrase. You will be asked for a passphrase for AES $1 ."
163
170
PASSPHRASE_FILE_AES_OPTION=" " # don't use this option
164
171
fi
165
172
}
@@ -419,12 +426,12 @@ esac
419
426
case " $1 " in
420
427
--help | --hel | --he | --h | -help | -hel | -he | -h)
421
428
usage
422
- cleanup_exit 0
423
- ;; # success
429
+ exit 0 # no cleanup needed
430
+ ;; # success
424
431
--version | --versio | --versi | --vers | --ver | --ve | --v | -version | -versio | -versi | -vers | -ver | -ve | -v)
425
432
usage
426
- cleanup_exit 0
427
- ;; # success
433
+ exit 0 # no cleanup needed
434
+ ;; # success
428
435
esac
429
436
430
437
# give some guidance, summary
@@ -478,4 +485,14 @@ for i in "$@"; do
478
485
fi
479
486
done
480
487
488
+ # This code is just useful if script is kicked off via GUI such as file manager
489
+ # Not needed when used in terminal.
490
+ # if [ "${FILESLASHSLASHUSED}" -eq "1" ]; then
491
+ # echo "${0##*/}: Done. Close window please by clicking X in top right window corner."
492
+ # else
493
+ # echo -n "${0##*/}: Hit any key to continue ... "
494
+ # fi
495
+ # read YESNO
496
+
481
497
cleanup_exit 0 # success
498
+ # EOF
0 commit comments