Skip to content

Instantly share code, notes, and snippets.

@flaviolopes
Created September 26, 2010 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flaviolopes/597573 to your computer and use it in GitHub Desktop.
Save flaviolopes/597573 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
#
#use strict;
#use warnings;
#
##use 5.010;
use 5.12.0;
#
use GnuPG qw( :algo );
use File::Find;
use File::Basename;
#
my $secret = "123456";
my @diretorios = "/home/flavio/teste_cripto/";
#
my $gpg = new GnuPG();
find( \&busca, @diretorios );
sub busca {
# Criptografa os arquivos dentro da arvore de diretorios
$gpg->encrypt(
plaintext => "$_",
output => "$_.gpg",
armor => 1,
sign => 0,
recipient => 0,
symmetric => 1,
passphrase => $secret
);
# Remove os arquivos originais e deixa somente os criptografados
if ( !/\.gpg$/ ) {
unlink $_ or warn "não foi possível remover arquivo \"$_\" => $!";
}
}
#!/usr/bin/perl
#
use strict;
use warnings;
#
#use 5.010;
##use 5.12.0;
#
use GnuPG qw( :algo );
use File::Find;
use File::Basename;
#
my $secret = "123456";
my @diretorios = "/home/flavio/teste_cripto/";
#
my $gpg = new GnuPG();
find( \&busca, @diretorios );
#sub busca {
#
# $gpg->decrypt(
# #ciphertext => "$_.gpg",
# ciphertext => " $_ ",
# output => " $_ ",
# symmetric => 1,
# passphrase => $secret
# );
#
#}
sub busca {
$gpg->decrypt(
#ciphertext => "$_.gpg",
ciphertext => "$_",
output => "$_.txt",
symmetric => 1,
passphrase => $secret
);
# if ( /\.gpg$/ ){
#
# unlink $_ or warn "não foi possível remover arquivo \"$_\" => $!";
# }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment