Created
October 9, 2016 19:58
-
-
Save leventebalogh/b7316884d12008eaee51c83b34852575 to your computer and use it in GitHub Desktop.
Storing passwords (fast and not the safest solution)
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
# Create a symlink to either /usr/local/bin, /usr/bin, or just add | |
# the container directory to the PATH. | |
# Run the script to open and edit your passwords. | |
FILE="$HOME/passwords.txt" | |
ENCRYPTED_FILE="$HOME/passwords.txt.gpg" | |
# Read in passwords | |
read -s -p "Enter password: " PASSWORD | |
# Delete passwords file if there | |
rm -rf $FILE | |
# Creating file | |
if [ ! -f $ENCRYPTED_FILE ]; then | |
echo "Encrypted file not found. Creating..." | |
touch $FILE | |
# Decrypting file | |
else | |
echo "Decrypting..." | |
gpg --passphrase "$PASSWORD" $ENCRYPTED_FILE | |
fi | |
# Successful | |
if [ -f $FILE ]; then | |
# Delete old version | |
rm -rf $ENCRYPTED_FILE | |
# Open | |
nano $FILE | |
# Encrypting | |
gpg -c --passphrase "$PASSWORD" $FILE | |
# Delete plain text version | |
rm -rf $FILE | |
echo -e "\nSuccessfully encrypted and saved." | |
# Decryption error | |
else | |
echo -e "\nBad password." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment