Created
September 26, 2010 03:36
-
-
Save flaviolopes/597573 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 \"$_\" => $!"; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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