#!/usr/bin/perl -w # Copyright (c) 2005 Flavio S. Glock. All rights reserved. # This program is free software; you can redistribute it # and/or modify it under the same terms as Perl itself. use strict; use Tk; { my $gpg = $0; $gpg =~ s/[a-z0-9.]+$/gpg.exe/i; exit unless @ARGV; my $main = MainWindow->new; $main->Label(-text => 'Passphrase')->pack; my $pass = $main->Entry(-width => 12, -show => '*'); $pass->pack; $main->Button(-text => 'Go', -command => sub { do_encrypt($pass, $gpg, @ARGV); $main->destroy; } )->pack; $main->Button(-text => 'Cancel', -command => [$main => 'destroy'] )->pack; MainLoop; } sub do_encrypt { my ($pass, $gpg, @files) = @_; my @cmd; for ( @files ) { if ( $_ =~ /(.*)\.gpg$/i ) { @cmd = ($gpg, '--decrypt', '--passphrase-fd 0', '-o', '"' . $1 . '"', '--batch', '--no-tty', '"' . $_ . '"', ); } else { @cmd = ($gpg, '--symmetric', '--passphrase-fd 0', '-o', '"' . $_ . '.gpg"', '--batch', '--no-tty', '"' . $_ . '"', ); } open( FILE, '|-', "@cmd" ); print FILE $pass->get, "\n"; close( FILE ); } }