#!/usr/bin/perl -w
use strict;
use Tk;
=head1 NAME
crypt_edit.pl
=head1 VERSION
0.1 (alpha)
=head1 SYNOPSIS
CryptEdit provides a quick text edit environment which saves directly
to an encrypted file, which removes the incredibly insecure step of
saving the text to a file on disk and then encrypting from there.
=head1 AUTHOR
Michael Libby
x@ichimunki.com
=head1 USAGE
C<crypt_edit.pl>
The program is set to use GnuPG using a keyring in a default location
(or with an options file readable from the default location. (I have
also included a sample that will use a keyring located on a floppy
disk on a Windows machine). You may need to alter the $PRIV_CMD to
operate with your install of PGP or GnuPG.
Enter a valid pathname/filename. Enter a recipient name.
Type your text (or even use cut and paste to insert text from
elsewhere), click the "Encrypt to File" button. Viola!
=cut
#user settings
#$PRIV_CMD must have a trailing space!
my $PRIV_CMD = "gpg ";
#my $PRIV_CMD = "pgp ";
#my $PRIV_CMD = "gpg --homedir A: ";
#construct the application window
my $mw = Tk::MainWindow->new();
#create action buttons
my $button_bar = $mw->Frame()->pack( -expand => 1, -fill => 'x');
my $button_encrypt =
$button_bar->Button( -text => 'Encrypt to File',
-command => \&encrypt_to_file );
my $button_exit =
$button_bar->Button( -text => 'Exit',
-command => \&exit_app );
$button_encrypt->pack( -side => 'left' );
$button_exit->pack( -side => 'left' );
#create entry fields
my $name_frame = $mw->Frame()->
pack( -expand => 1,
-fill => 'x'
);
my $name_label = $name_frame->Label( text => 'Filename:')->
pack( -side => 'left' );
my $name_entry = $name_frame->Entry()->
pack( -side => 'right',
-fill => 'x',
-expand => 1
);
my $recip_frame = $mw->Frame()->
pack( -expand => 1,
-fill => 'x'
);
my $recip_label = $recip_frame->Label( text => 'Recipient:')->
pack( -side => 'left' );
my $recip_entry = $recip_frame->Entry()->
pack( -side => 'right',
-fill => 'x',
-expand => 1
);
#create main text area
my $text_box =
$mw->Scrolled( 'Text',
'-scrollbars' => 'e',
)->
pack();
MainLoop;
sub encrypt_to_file
{
#get privacy call command
my $priv_call = $PRIV_CMD;
$priv_call .= "-r " . $recip_entry->get() . " ";
$priv_call .= "-o " . $name_entry->get() . " ";
$priv_call .= "--encrypt ";
#get text
my $text = $text_box->get('1.0', 'end');
#open pipe to privacy command
open( PRIVACY, "| $priv_call");
print PRIVACY $text;
close PRIVACY;
}
sub exit_app
{
#add check if text changed since last saved or signed?
exit;
}
=head1 COPYRIGHT
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
Also available in full at http://www.gnu.org/licenses/gpl.html
=cut
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.