Adding encryption and decryption
This commit is contained in:
parent
b273d23d77
commit
0410f65b19
11
README.md
11
README.md
|
@ -42,6 +42,17 @@ Converts currency based on realtime exchange rates
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
## Encryption & Decryption
|
||||||
|
|
||||||
|
A wrapper for openssl that allows for quickly encrypting and decrypting files
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
<img max-height="500px" max-width="500px" src="https://github.com/alexanderepstein/Bash-Snippets/blob/master/crypt/crypt.png?raw=true">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
#### To Be Added
|
#### To Be Added
|
||||||
[ ] Pass in arguments as well on top of the option to have it guide you through input
|
[ ] Pass in arguments as well on top of the option to have it guide you through input
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Author: Alexander Epstein https://github.com/alexanderepstein
|
||||||
|
|
||||||
|
encrypt()
|
||||||
|
{
|
||||||
|
openssl enc -aes-256-cbc -salt -a -in $1 -out $2 || { echo "File not found"; exit 1; }
|
||||||
|
echo "Successfully encrypted"
|
||||||
|
}
|
||||||
|
|
||||||
|
decrypt()
|
||||||
|
{
|
||||||
|
openssl enc -aes-256-cbc -d -a -in $1 -out $2 || { echo "File not found"; exit 1; }
|
||||||
|
echo "Successfully decrypted"
|
||||||
|
}
|
||||||
|
|
||||||
|
while getopts ":e:d::" opt; do
|
||||||
|
case $opt in
|
||||||
|
e)
|
||||||
|
if [[ $# -gt 3 ]]; then
|
||||||
|
echo "Option -e only accepts two arguments" <&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
encrypt $2 $3
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo "Invalid option: -$OPTARG" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
d)
|
||||||
|
if [[ $# -gt 3 ]]; then
|
||||||
|
echo "Option -e only accepts two arguments" <&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
decrypt $2 $3
|
||||||
|
;;
|
||||||
|
:)
|
||||||
|
echo "Option -$OPTARG requires an argument." >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
Binary file not shown.
After Width: | Height: | Size: 65 KiB |
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Author: Alexander Epstein https://github.com/alexanderepstein
|
||||||
|
echo -n "Installing crypt: "
|
||||||
|
chmod a+x crypt
|
||||||
|
cp crypt /usr/local/bin > /dev/null 2>&1 || { echo "Failure"; echo "Error copying file, try running install script as sudo"; exit 1; }
|
||||||
|
echo "Success"
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Author: Alexander Epstein https://github.com/alexanderepstein
|
||||||
|
echo -n "Removing crypt: "
|
||||||
|
rm -f /usr/local/bin/crypt > /dev/null 2>&1 || { echo "Failed" ; echo "Error removing file, try running uninstall script as sudo"; exit 1; }
|
||||||
|
echo "Success"
|
13
install.sh
13
install.sh
|
@ -1,10 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Author: Alexander Epstein https://github.com/alexanderepstein
|
# Author: Alexander Epstein https://github.com/alexanderepstein
|
||||||
cd currency
|
cd currency || exit 1
|
||||||
./install.sh || exit 1
|
./install.sh || exit 1
|
||||||
cd ..
|
cd .. || exit 1
|
||||||
cd stocks
|
cd stocks || exit 1
|
||||||
./install.sh
|
./install.sh
|
||||||
cd ..
|
cd .. || exit 1
|
||||||
cd weather
|
cd weather || exit 1
|
||||||
|
./install.sh
|
||||||
|
cd .. || exit 1
|
||||||
|
cd crypt || exit 1
|
||||||
./install.sh
|
./install.sh
|
||||||
|
|
13
uninstall.sh
13
uninstall.sh
|
@ -1,10 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Author: Alexander Epstein https://github.com/alexanderepstein
|
# Author: Alexander Epstein https://github.com/alexanderepstein
|
||||||
cd currency
|
cd currency || exit 1
|
||||||
./uninstall.sh || exit 1
|
./uninstall.sh || exit 1
|
||||||
cd ..
|
cd .. || exit 1
|
||||||
cd stocks
|
cd stocks || exit 1
|
||||||
./uninstall.sh
|
./uninstall.sh
|
||||||
cd ..
|
cd .. || exit 1
|
||||||
cd weather
|
cd weather || exit 1
|
||||||
|
./uninstall.sh
|
||||||
|
cd .. || exit 1
|
||||||
|
cd crypt || exit 1
|
||||||
./uninstall.sh
|
./uninstall.sh
|
||||||
|
|
Loading…
Reference in New Issue