Tool

David Crouse's picture
tool
Reads:

3363

Score:
0
0
 
Comments:

0

Bash Passphrase Encryption

Author Info

9 March 2006 - 11:47am
Submitted by: David Crouse

download url: 
http://www.bashscripts.org/downloads/Scripts/crouse/passphraseencryption.sh
license: 
GPL

I wanted a quick and easy way to encrypt text for people that I didn't have public keys for. This allows for some security, and for easy decryption. For decrypting, my favorite method is to just copy the message to my clipboard and use KGpg to decrypt it. KGpg will ask you for the passphrase, and not require a public key to decrypt, just the correct passphrase will do.

#!/bin/bash
# Passphrase encryption program
# Created by Dave Crouse 01-13-2006
# Reads input from text editor and encrypts to screen.
clear
echo "         Passphrase Encryption Program";
echo "--------------------------------------------------"; echo "";
which $EDITOR &>/dev/null
  if [ $? != "0" ];
      then
      echo "It appears that you do not have a text editor set in your
.bashrc file.";
      echo "What editor would you like to use ? " ;
      read EDITOR ; echo "";
  fi
echo "Enter the name/comment for this message :"
read comment
$EDITOR passphraseencryption
gpg --armor --comment "$comment" --no-options --output
passphraseencryption.gpg --symmetric passphraseencryption
shred -u passphraseencryption ; clear
echo "Outputting passphrase encrypted message"; echo "" ; echo "" ;
cat passphraseencryption.gpg ; echo "" ; echo "" ;
shred -u passphraseencryption.gpg ;
exit

Sample Message:
-----------------

-----BEGIN PGP MESSAGE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Sample Passphrase Encrypted Message. The passphrase is "Cool Tools"

jA0EAwMC8azAMTdl43RgycB44mENw4QaIDeOdI/yuhWtk/2CNzf4zZgho0tnJVux
pmQFM/k/BLDjHo7HWcZCa63H/CqdUSkGAi0JGgTc2/35rUsjSfw2uD8ZsJVY/K0W
fOlRK41AnEzoqFhw4RqBnAN0Cyk4761un6N/ZwjsMdR4UQzeRqBYfFXv9AWneAEJ
+ORgKkhytsNuHrsyaeqSr8ZnpD2axsWtik8rCOerwUAMVbsrOhgcLZKdo1dBouf5
Vy51VkCxUSoJ9lDJLcEAwHghrGvQpF+xx/c3qghIgSUxKy0PZmBiWXJXsyzFWITa
mz0zk5McwGbvnqeDNNoM/y8M4N6mtqLHgjrtdtypo76dQ+o4yhonnmvrfMrS4H2T
tIlovzmjx+4glev0qDLJ7DO/Vv+6CCWb6Ev/sc01uWLwEpznBHziLBqi
=YVts
-----END PGP MESSAGE-----

Obviously you NORMALLY wouldn't put the passphrase in the comments section of the message, I did that just so you could decrypt it and see how that worked. Your passphrase would normally be much longer and more complex, but for the sake of explanation, two words "Cool Tools" made up my passphrase in this example.

Originally posted on: http://www.bashscripts.org/viewtopic.php?t=158
Download: http://www.bashscripts.org/downloads/Scripts/crouse/passphraseencryption.sh





User Comments

© 2013 Novell