Skip to content

Instantly share code, notes, and snippets.

@AysadKozanoglu
Last active November 5, 2020 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AysadKozanoglu/1efd8c78909a528915001f9477770684 to your computer and use it in GitHub Desktop.
Save AysadKozanoglu/1efd8c78909a528915001f9477770684 to your computer and use it in GitHub Desktop.
AES256 bit easy encrypt decrypt file handler script , encryption based on openssl
#!/bin/bash
#####################################################
# Author: Aysad Kozanoglu
#
# OS: Debian / Ubuntu / all derivates of Debian
#
# Usage: file_encrypter.sh enc|dec FILENAME (without Ending .plain or .enc)
# example: ./file_encrypter.sh enc FILENAME
# create first NEW_FILENAME.plain with plain content
#####################################################
if $(which openssl> /dev/null);
then
echo "openssl found, OK...";
else
sudo apt-install -y -q openssl;
fi
if [ -z "$2" ] || [ -z "$1" ];
then
echo "error "; exit 1;
fi
if [ $1 == "enc" ];
then
openssl aes-256-cbc -a -salt -in ${2}.plain -out ${2}.enc
rm -i ${2}.plain
exit 0
fi
if [ $1 == "dec" ];
then
openssl aes-256-cbc -d -a -in ${2}.enc -out ${2}.plain
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment