BashScripts.org
http://bashscripts.org/forum/

Passphrase encryption program
http://bashscripts.org/forum/viewtopic.php?f=7&t=158
Page 1 of 1

Author:  crouse [ Fri Jan 13, 2006 4:50 pm ]
Post subject:  Passphrase encryption program

Code:
#!/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

Author:  coastie [ Sat Jul 22, 2006 10:24 pm ]
Post subject: 

how would i encrypt a file with a specified passphrase....ie...summer would be the pass phrase, theoretically

Author:  jbsnake [ Sun Jul 23, 2006 8:55 pm ]
Post subject: 

my passphrase encryption program...
it encrypts any file... and appends the file name with .gpg..
if you named them encrypt_it
you would call it like:
encrypt_it /file/to/encrypt
Code:
#!/bin/bash

gpg --armor --comment "Encrypted by jbsnake" --no-options --output "${1}.gpg" --symmetric "${1}"


my passphrase decryption program...
it decrypts any file... and removes the .gpg at the end of a file name
if you called this one decrypt_it
you would call it like:
decrypt_it /file/to/decrypt.gpg
Code:
#!/bin/bash

gpg --decrypt --output "${1:0:${#1}-4}" "${1}"


obviously there could be more to them... but i just needed something quick and dirty

Author:  crouse [ Mon Jul 24, 2006 7:54 am ]
Post subject: 

coastie wrote:
how would i encrypt a file with a specified passphrase....ie...summer would be the pass phrase, theoretically


When using a passphrase vs using keys... it's called --symmetric encryption. I probably should have used the title symmetric encryption, but passphrase made more sense to me at the time :D

So, doing a "man gpg" ..... look for the symmetric option, and it will tell you all about it i'm sure :D :D The man page for gpg is pretty detailed, 1500 + lines on my system..... the most used stuff is right at the top though.

I hadn't thought of a decrypting or encrypting routine for files coastie, that's a great idea :)

Author:  coastie [ Mon Jul 24, 2006 1:29 pm ]
Post subject: 

did you get the gift i left for you :? look at my account on your ftp :idea:

Author:  coastie [ Tue Jul 25, 2006 1:02 pm ]
Post subject: 

ok i figured out the encryption using a passphrase.

Code:
gpg -c filename.ext


you are then prompted for the passphrase :D

Author:  digitaljunkie [ Tue Jun 05, 2007 4:15 am ]
Post subject: 

coastie wrote:
ok i figured out the encryption using a passphrase.

Code:
gpg -c filename.ext


you are then prompted for the passphrase :D


just to follow-up from this when I decrypt something I get this error after it decrypts...

"gpg: WARNING: message was not integrity protected"


What does this mean?

Also If i encrypt a native file does gpg preserve the files structure and resources?
I'm thinking of a filemaker database file that I want to backup.

Page 1 of 1 All times are UTC - 6 hours
© 2000, 2002, 2005, 2007 phpBB Group • http://www.phpbb.com