Jump to content

GPG made easier


Recommended Posts

I hope anyway! I put together 2 scripts to make it easy to pipe strings into/out of gpg from the commandline and I have found it useful

$ cat ./encrypt.sh
cat - | gpg --encrypt -r $(gpg --list-secret-keys | grep '^sec ' | head -n 1 | cut -d\  -f4 | cut -d/ -f2)

$ cat ./decrypt.sh
exec 3<> $TEMPFILE
cat - >&3
zenity --password --title="Passphrase" --cancel-label="Skip"  | gpg --no-tty --passphrase-fd 0 --decrypt -q --no-use-agent $TEMPFILE
if [ -x $(which shred) ]; then
	shred -z -n 6 -u $TEMPFILE;
	rm -f $TEMPFILE;
exec 3>&-
So you should be able to do things like:

$ echo 'Hello World' | ./encrypt.sh > encfile.bin
$ cat encfile.bin | ./decrypt.sh
Hello World
I've tested it somewhat and it seems to work well. But it might not work well if you system has more then one

secret key on it, cause it uses the first public/secret key pair it finds in your gpg keyring.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...