#4 - Adding ignore hash
This commit is contained in:
parent
9ba397e477
commit
d66ca83f95
@ -1,7 +1,7 @@
|
|||||||
# Crypter
|
# Crypter
|
||||||
Script to encrypt and decrypt files easily using openssl.
|
Script to encrypt and decrypt files easily using openssl.
|
||||||
## Howto
|
## Howto
|
||||||
./crypter.sh -[e/d] [inputfile] --no-verify
|
./crypter.sh -[e/d] inputfile [--no-verify]
|
||||||
### Options
|
### Options
|
||||||
-e for encrypt - Encrypts the filename and adds a hash file.
|
-e for encrypt - Encrypts the filename and adds a hash file.
|
||||||
-d for decrypt - Decrypts the file and removes crypt files after hash check.
|
-d for decrypt - Decrypts the file and removes crypt files after hash check.
|
||||||
|
31
crypter.sh
31
crypter.sh
@ -12,7 +12,7 @@ then
|
|||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Usage: ./crypter.sh -[e/d] [inputfile]";
|
echo "Usage: ./crypter.sh -[e/d] inputfile [--no-verify]";
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ case "$1" in
|
|||||||
else
|
else
|
||||||
# NOK - remove empty output file
|
# NOK - remove empty output file
|
||||||
echo "CRITICAL - Output file ${OUTPUT} is 0 bytes! Not removing the source file ${INPUT}"
|
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
|
exit 2
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@ -54,20 +54,27 @@ case "$1" in
|
|||||||
rm -f ${INPUT}.temp
|
rm -f ${INPUT}.temp
|
||||||
if [ "`stat ${OUTPUT} | grep Size | awk '{ print $2}'`" != 0 ]
|
if [ "`stat ${OUTPUT} | grep Size | awk '{ print $2}'`" != 0 ]
|
||||||
then
|
then
|
||||||
# SHA256SUM CHECK
|
if [ "$3" != '--no-verify' ]
|
||||||
CUR_HASH=$(sha256sum --quiet --check ${OUTPUT}.crypt.hash)
|
|
||||||
if [ $? != 0 ]
|
|
||||||
then
|
then
|
||||||
# NOK - Hash mismatch
|
# SHA256SUM CHECK
|
||||||
echo "CRITICAL - Hashes mismatching!"
|
CUR_HASH=$(sha256sum --quiet --check ${OUTPUT}.crypt.hash)
|
||||||
rm -f ${OUTPUT}
|
if [ $? != 0 ]
|
||||||
exit 2
|
then
|
||||||
|
# NOK - Hash mismatch
|
||||||
|
echo "CRITICAL - Hashes mismatching!"
|
||||||
|
rm -f ${OUTPUT}
|
||||||
|
exit 2
|
||||||
|
else
|
||||||
|
# OK - safe to delete the original input file
|
||||||
|
echo "OK - Hashes matching, deleting input file"
|
||||||
|
rm -f ${INPUT} ${INPUT}.hash
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# OK - safe to delete the original input file
|
echo "Ignoring hash verify"
|
||||||
echo "OK - Hashes matching, deleting input file"
|
|
||||||
rm -f ${INPUT} ${INPUT}.hash
|
rm -f ${INPUT} ${INPUT}.hash
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
# NOK - remove empty output file
|
# NOK - remove empty output file
|
||||||
echo "CRITICAL - Output file is 0 bytes! Not removing the input file"
|
echo "CRITICAL - Output file is 0 bytes! Not removing the input file"
|
||||||
|
Loading…
Reference in New Issue
Block a user