Skip to content

Commit ed65be3

Browse files
author
8go
authored
changed hash iterations
1 parent ef736e0 commit ed65be3

File tree

1 file changed

+30
-13
lines changed

1 file changed

+30
-13
lines changed

openssl-encrypt-twice-symmetrically.sh

+30-13
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
# If this software does not suit you, here are some alternative pieces of
77
# 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
1011
# https://github.com/SixArm/gpg-encrypt
1112
# https://github.com/SixArm/gpg-decrypt
1213
# https://github.com/SixArm/openssl-encrypt
@@ -48,7 +49,9 @@ UMASK_READONLY="0377" # created files (will be r--)
4849
# SHA_HASH_ITERATIONS: -iter 100,000,000 roughly 1 min on basic average 2020 CPU, tested
4950
# SHA_HASH_ITERATIONS: -iter 1,000,000,000 roughly 10 min on basic average 2020 CPU, tested
5051
# 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
5255
SHA_HASH_ITERATIONS=$SHA_HASH_ITERATIONS_RECOMMENDED # 100M
5356
# SHA_HASH_ITERATIONS=100000 # 100K # for testing only
5457
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"
6265

6366
# usage: outputs to stdout the --help usage message.
6467
usage() {
65-
echo "${0##*/}: Version: v2020-09-30"
68+
echo "${0##*/}: Version: v2020-11-02"
6669
echo "${0##*/}: Usage: ${0##*/} [--help] [--encrypt|--decrypt] files"
6770
echo "${0##*/}: e.g. ${0##*/} file1.txt file2.jpg # encrypt 2 files"
6871
echo "${0##*/}: e.g. ${0##*/} # read from stdin, encrypt text from stdin input"
@@ -81,11 +84,11 @@ usage() {
8184
echo "${0##*/}: If no file is provided as command line argument, script will read "
8285
echo "${0##*/}: plain-text from std input."
8386
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"
8588
echo "${0##*/}: directory, then it will be used as passphrase source instead of stdin"
8689
echo "${0##*/}: for the Chacha20-round (first round) of encryption."
8790
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"
8992
echo "${0##*/}: directory, then it will be used as passphrase source instead of stdin"
9093
echo "${0##*/}: for the AES-round (second round) of encryption."
9194
echo "${0##*/}: "
@@ -97,9 +100,10 @@ usage() {
97100
echo "${0##*/}: Decrypt does the opposite. It recovers the plaintext from the ciphertext."
98101
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."
99102
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
103107
$ ./${0##*/}
104108
${0##*/}: Install latest version of "openssl", "shred" and "qrencode"!
105109
${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"
127131
${0##*/}: Meta data is in file "ciphertext.inf"
128132
${0##*/}: SUCCESS! Look at ciphertext output in file "ciphertext.enc".
129133
END
134+
fi
130135
} # usage()
131136

132137
# takes 1 optional argument, the return value, the exit value
@@ -155,11 +160,13 @@ read-passphrase-files-if-availble() {
155160
if [ -f "$PASSPHRASE_FILE_CHACHA_FILE" ]; then
156161
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."
157162
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."
158164
PASSPHRASE_FILE_CHACHA_OPTION="" # don't use this option
159165
fi
160166
if [ -f "$PASSPHRASE_FILE_AES_FILE" ]; then
161167
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."
162168
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."
163170
PASSPHRASE_FILE_AES_OPTION="" # don't use this option
164171
fi
165172
}
@@ -419,12 +426,12 @@ esac
419426
case "$1" in
420427
--help | --hel | --he | --h | -help | -hel | -he | -h)
421428
usage
422-
cleanup_exit 0
423-
;; # success
429+
exit 0 # no cleanup needed
430+
;; # success
424431
--version | --versio | --versi | --vers | --ver | --ve | --v | -version | -versio | -versi | -vers | -ver | -ve | -v)
425432
usage
426-
cleanup_exit 0
427-
;; # success
433+
exit 0 # no cleanup needed
434+
;; # success
428435
esac
429436

430437
# give some guidance, summary
@@ -478,4 +485,14 @@ for i in "$@"; do
478485
fi
479486
done
480487

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+
481497
cleanup_exit 0 # success
498+
# EOF

0 commit comments

Comments
 (0)