Skip to content

Commit

Permalink
Switched to OpenSSL AES encryption, some other small adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
hmarr committed Aug 23, 2009
1 parent 5a03b27 commit 651e0a1
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 66 deletions.
9 changes: 2 additions & 7 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@ It simply decrypts the file into a file readable only by you, you edit it in you

I use this to keep track of my web passwords.

Usage :

$ ./gpg-encrypt.sh
No filename specified. Using default passwords.gpg
Password:
passwords.gpg doesn't exist. Starting from empty file.
Usage: ./aesvi passwords.aes
<editor pops up and you edit your file. Once you exit it saves it encrypted>

To change your editor (in bash) :
$ export EDITOR=pico
$ ./gpg-encrypt.sh
$ ./aesvi passwords.aes
<now pico pops up>
56 changes: 56 additions & 0 deletions aesvi
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

# Select text editor (default to vi)
if [ $EDITOR ]; then
editor=$EDITOR
elif [ -f /usr/bin/editor ]; then
editor=/usr/bin/editor
else
editor=vi
fi

if [[ $# = 0 || $# > 1 ]]; then
echo "Usage: aesvi [filename]"
exit 2
else
filename=$1
fi

# Use shred (with -u to remove file) if available
if [ -f `which shred` ]; then
rm="shred -u"
else
rm=rm
fi

tmp=`mktemp` || exit 1

# Don't show the password as it's being typed
stty -echo
read -p "Password: " passwd; echo
stty echo

if [ ! -f $filename ]; then
echo "$filename doesn't exist. Starting from empty file."
elif [ ! -w $filename ]; then
echo "$filename isn't writable."
exit 1
else
# Decrypt into the tmp file
openssl aes-256-cbc -a -d -in $filename -out $tmp -pass pass:$passwd \
2> /dev/null
ret=$?
if [ $ret != 0 ]; then
echo "Error: decryption fail"
$rm $tmp
exit $ret;
fi
fi

# Encrypt the file and remove the tmp file
$editor $tmp
openssl aes-256-cbc -a -salt -in $tmp -out $filename -pass pass:$passwd \
2> /dev/null
ret=$?
$rm $tmp
exit $ret
59 changes: 0 additions & 59 deletions gpg-encrypt.sh

This file was deleted.

0 comments on commit 651e0a1

Please sign in to comment.