#4 - Adding ignore hash

This commit is contained in:
Frank Bischof 2024-04-17 12:17:09 +02:00
parent 9ba397e477
commit d66ca83f95
2 changed files with 20 additions and 13 deletions

View File

@ -1,7 +1,7 @@
# Crypter
Script to encrypt and decrypt files easily using openssl.
## Howto
./crypter.sh -[e/d] [inputfile] --no-verify
./crypter.sh -[e/d] inputfile [--no-verify]
### Options
-e for encrypt - Encrypts the filename and adds a hash file.
-d for decrypt - Decrypts the file and removes crypt files after hash check.

View File

@ -12,7 +12,7 @@ then
exit 2
fi
else
echo "Usage: ./crypter.sh -[e/d] [inputfile]";
echo "Usage: ./crypter.sh -[e/d] inputfile [--no-verify]";
exit 1
fi
@ -42,7 +42,7 @@ case "$1" in
else
# NOK - remove empty output file
echo "CRITICAL - Output file ${OUTPUT} is 0 bytes! Not removing the source file ${INPUT}"
rm -f ${OUTPUT} ${INPUT}.hash
rm -f ${OUTPUT} ${OUTPUT}.hash
exit 2
fi
;;
@ -53,6 +53,8 @@ case "$1" in
openssl enc -d ${ALGOS} -in ${INPUT}.temp -out ${OUTPUT} > /dev/null 2>&1
rm -f ${INPUT}.temp
if [ "`stat ${OUTPUT} | grep Size | awk '{ print $2}'`" != 0 ]
then
if [ "$3" != '--no-verify' ]
then
# SHA256SUM CHECK
CUR_HASH=$(sha256sum --quiet --check ${OUTPUT}.crypt.hash)
@ -68,6 +70,11 @@ case "$1" in
rm -f ${INPUT} ${INPUT}.hash
exit 0
fi
else
echo "Ignoring hash verify"
rm -f ${INPUT} ${INPUT}.hash
fi
else
# NOK - remove empty output file
echo "CRITICAL - Output file is 0 bytes! Not removing the input file"