I just wrote up these two bash scripts and decided to share them here in the hope that they may be useful to other forum users.
encrypt
decrypt
Signed,
Matthew Campbell
encrypt
Code:
#!/bin/bash
#
# Uses /usr/bin/openssl to encrypt a file.
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ] || [ ! -z "$5" ]; then
echo "Usage: encrypt <input file name> <output file name> <number of iterations> <password>"
exit 1
fi
# The number of iterations is used to derive the encryption key from the password.
/usr/bin/openssl enc -aes-256-cbc -salt -pbkdf2 -iter "$3" -in "$1" -out "$2" -pass pass:"$4"
exit $?
# EOF
decrypt
Code:
#!/bin/bash
#
# Uses /usr/bin/openssl to decrypt a file.
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ] || [ ! -z "$5" ]; then
echo "Usage: decrypt <input file name> <output file name> <number of iterations> <password>"
exit 1
fi
# The number of iterations is used to derive the decryption key from the password.
/usr/bin/openssl enc -aes-256-cbc -d -salt -pbkdf2 -iter "$3" -in "$1" -out "$2" -pass pass:"$4"
exit $?
# EOF
Signed,
Matthew Campbell
Last edited: