Last active
November 5, 2020 14:31
-
-
Save AysadKozanoglu/1efd8c78909a528915001f9477770684 to your computer and use it in GitHub Desktop.
AES256 bit easy encrypt decrypt file handler script , encryption based on openssl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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