Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Drag-and-drop encrypting files in a pen drive

by fglock (Vicar)
on Jul 05, 2005 at 21:21 UTC ( #472610=snippet: print w/replies, xml ) Need Help??

How to use: drag and drop files into the executable icon. You will be asked for a password. The program will then create encrypted files with the ".gpg" extension (it will not delete the original files for you).

If you drop files with the ".gpg" extension, the files will be un-encrypted back.

Installation: use "PAR" (or Perl2EXE/PerlApp) to make an executable file, and copy it to the pen drive. You will need to copy the "gpg" executable to the same directory.

I've tested it with perlapp, in Windows XP and NT.

#!/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 => '*');
    $main->Button(-text => 'Go',
                  -command => sub {
                           do_encrypt($pass, $gpg, @ARGV);

    $main->Button(-text => 'Cancel',
                  -command => [$main => 'destroy']

sub do_encrypt {
    my ($pass, $gpg, @files) = @_;
    my @cmd;
    for ( @files )
        if ( $_ =~ /(.*)\.gpg$/i )
            @cmd = ($gpg,
                '--passphrase-fd 0',
                '-o', '"' . $1 . '"',
                '--batch', '--no-tty',
                '"' . $_ . '"',
            @cmd = ($gpg,
                '--passphrase-fd 0',
                '-o', '"' . $_ . '.gpg"',
                '--batch', '--no-tty',
                '"' . $_ . '"',
        open( FILE, '|-', "@cmd" );
        print FILE $pass->get, "\n";
        close( FILE );
Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://472610]
[Discipulus]: always! but if i can ask choroba why you always use the inverted (to me) form 1 == $.?
[choroba]: To avoid accidental overwriting of the variable in if ($x = 3)
[karlgoethebier]: Corion: Auch in hessisch? Mer wasses net.
[Corion]: Hmm - I'm not sure, I haven't read the mundart/slang translations ;)
[Eily]: $F[1] =~ s/^0//r could be written as (0+$F[1]). It's less explicit though
[Discipulus]: ah! seems wise choroba, you play safe
[shmem]: Eily: also -+-$F[1]
[shmem]: hmm... there should be a glyph for "bembel" in unicode "miscellaneous symbols"

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2017-05-24 08:42 GMT
Find Nodes?
    Voting Booth?