Register
It is currently Fri Oct 31, 2014 1:14 pm

enc/dec Symmetric Cipher Encryption GUIs using Zenity.


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Wed Aug 08, 2007 10:32 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 669
Location: Des Moines, Iowa
enc/dec Symmetric Cipher Encryption GUIs using Zenity.

I stuck mine in /usr/bin/ so i could just call the with "enc" or "dec" ...... obviously enc=encrypt and dec=decrypt ...... These are pretty self explanatory once you use them once. They need to use bash and zenity, so you can't call them with "sh dec" it needs to be "./dec" or if you've put them in your path ..... just "dec" should work. Once I have mine in /usr/bin/ ..... i usually create icons on the desktop that link to them ......... allowing me to with a click, encrypt or decrypt a message.

This is the first release of these two ....... so let me know of any "gotcha's". Being symmetric encryption, they aren't going to be NSA proof or anything, but I would like to have the script as secure as possible, so if there is anything you think i should do differently, let me know.

You can download them here
Code:
wget http://crouse.us/scripts/bash/encryption/dec ; wget http://crouse.us/scripts/bash/encryption/enc; chmod a+x dec; chmod a+x enc


Here is the code so far.
ENC
Code:
#!/bin/bash
# FILE: enc
# A Symmetric Cipher Encryption GUI Utility made using Zenity
# Copyright (C) 2007 Dave Crouse
# Requires bash,gpg,zenity,shred
if [[ -z $( type -p gpg ) ]]; then echo -e "gpg -- NOT INSTALLED !";exit ;fi
if [[ -z $( type -p zenity ) ]]; then echo -e "zenity -- NOT INSTALLED !";exit ;fi
if [[ -z $( type -p shred ) ]]; then echo -e "shred -- NOT INSTALLED !";exit ;fi

trap cleanup 0 1 2 3 6

cleanup()
{
shred -u passphraseencryption ;shred -u passphraseencryption.gpg ;
key_Master="";key_A="987";key_B="123"
  exit 1
}

key_phrase () {
   key_Master=""
   key_A="987"
   key_B="123"
   
   while [ "$key_Master" == "" ] ; do
      key_A=`zenity --entry --width=600 --title="Symmetric Cipher Encryption - Enter KEY or Passphrase:" --text="Enter key or phrase for symmetric cipher" --hide-text`
      if [ $? -ne 0 ] ; then
         echo "Cancelled"
         exit 1
      fi
      key_B=`zenity --entry  --width=600 --title="Please re-enter the passphrase or key here to confirm:" --text="Please re-enter key or phrase to confirm" --hide-text`
      if [ $? -ne 0 ] ; then
         echo "Cancelled"
         exit 1
      fi

      if [ "$key_A" == "$key_B" ] ; then
         key_Master="$key_A"
      else
         zenity --warning --width=600 --text="WARNING: Passphrase didn't match. Try again." --title="Symmetric Cipher Encryption"
      fi
   done
}

comment=`zenity --entry  --width=600 --title="Symmetric Cipher Encryption - Enter Comment" --text="Please enter a comment here for the encrypted message:"`
key_phrase
zenity --text-info --title="Symmetric Cipher Encryption - Enter Text to be encrypted." --width=600 --height=500 --editable > passphraseencryption
gpg --armor --comment "$comment" --passphrase "$key_Master" --no-options --output passphraseencryption.gpg --symmetric passphraseencryption
zenity --text-info --title="This is the encrypted message." --width=600 --height=500 --filename=passphraseencryption.gpg
exit 0



DEC
Code:
#!/bin/bash
# FILE: dec
# A Symmetric Cipher Decryption GUI Utility made using Zenity
# Copyright (C) 2007 Dave Crouse
# Requires bash,gpg,zenity,shred
if [[ -z $( type -p gpg ) ]]; then echo -e "gpg -- NOT INSTALLED !";exit ;fi
if [[ -z $( type -p zenity ) ]]; then echo -e "zenity -- NOT INSTALLED !";exit ;fi
if [[ -z $( type -p shred ) ]]; then echo -e "shred -- NOT INSTALLED !";exit ;fi

trap cleanup 0 1 2 3 6

cleanup()
{
shred -u decrypt.txt ;shred -u encrypted.txt ;
decryption_key="";
exit 1
}

get_key () {
decryption_key=`zenity --entry --width=600 --title="Symmetric Cipher Decryption - Enter KEY or Passphrase" --text="Enter key or phrase for symmetric cipher decryption" --hide-text`
if [ $? -ne 0 ] ; then
echo "Cancelled"
exit 1
fi
}

decryptz () {
gpg --passphrase "$decryption_key" --output decrypt.txt --decrypt encrypted.txt
}

zenity --text-info --title="Symmetric Cipher Decryption - Enter Text to be decrypted in this box." --width=600 --height=500 --editable > encrypted.txt
get_key
decryptz
zenity --text-info --title="Symmetric Cipher Decryption - Decrypted Message" --width=600 --height=500 --filename=decrypt.txt
exit 0



Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP