Hi all,
I'got an explanation about the IPC error.
After I've rebooted my PC, the script is passing without any issue.
If I run it on a newer/more powerfull/... PC, I can make it pass as well.
Then means that after several trials of my script => several decryption, untar, tar and diff commands, the internal memory (lets call it that way) becomes full and some commands make the script to fail.
About the decryption with "use Crypt::GPG", I still can't make it work. I can create an armour encrypted file as suggested by Tobyink but I can't decrypt it.
Here is the code I'm using :
#!/usr/bin/perl
use strict ;
use Crypt::GPG ;
use Archive::Tar ;
my $gpg = new Crypt::GPG ;
$gpg->gpgbin('/bin/gpg') ;
$gpg->secretkey('my_email_address') ;
$gpg->passphrase('my_gpg_passphrase') ;
$gpg->armor(1) ;
my $encryptedFile = '/home/xuo/TheCat.gpg' ;
my $tarFile_read = '/home/xuo/TheCat.tar.gz' ;
my $tarFile_write = '/home/xuo/TheCat_from_gpg_encrypt.gpg' ;
my @encryptedFileArray = () ;
my @fileToBeEncrypted = () ;
my @fileToBeDecrypted = () ;
my @gpgEncryptedFile = () ;
open(TAR_FILE, "$tarFile_read") || die "can't open file $tarFile_read
+!" ;
@fileToBeEncrypted = <TAR_FILE> ;
close(TAR_FILE) ;
my @gpgEncryptedFile = $gpg->encrypt(\@fileToBeEncrypted, 'my_email_ad
+dress') ;
open(GPG_FILE, ">$encryptedFile") || die "can't open file $encryptedFi
+le !" ;
print GPG_FILE "@gpgEncryptedFile" ;
close(GPG_FILE) ;
open(GPG_FILE, "$encryptedFile") || die "can't open file $encryptedFil
+e !" ;
@fileToBeDecrypted = <GPG_FILE> ;
close(GPG_FILE) ;
my ($plaintext, $signature) = $gpg->verify(\@fileToBeDecrypted) ;
open(TAR_FILE, ">$tarFile_write") || die "can't open file $tarFile_wri
+te !" ;
print TAR_FILE "$plaintext" ;
close(TAR_FILE) ;
exit ;
$ more TheCat.gpg
-----BEGIN PGP MESSAGE-----
Comment: Crypt::GPG v1.64
hQEMA8z8x+FbnSQ6AQf9FXqGTJuwvp4uI51iZSmioyROTK0XkkHUHqnGhJYhJAdN
zQliHEr1ubGHFtcmI7qg4dNpKTZcKD5XWoTNWMEK98CV9t/dzlXVrjlBIT8ztTlQ
5dTJiU0E/SenMpnTTOERL5hm4qIW5+TWWF1zYsuBFIB/4TLX6GrABNTUlNWhsL95
This is a pgp-armored file but the decrypted file is of size 0.
Regards.
Xuo.
| [reply] [d/l] |
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
use Crypt::GPG;
my $gpg = Crypt::GPG->new;
$gpg->gpgbin ('/usr/bin/gpg');
$gpg->secretkey ($ENV{SECRET_KEY});
$gpg->passphrase ($ENV{GPG_PP});
$gpg->armor (1);
my $plaintext = 'PerlMonks Rocks!';
say "Plain text: $plaintext";
my @enctext = $gpg->encrypt ([$plaintext], $ENV{TO_EMAIL});
say "Encrypted text: @enctext";
my $decrypted = $gpg->verify (\@enctext);
say "Decrypted text: $decrypted";
| [reply] [d/l] |
Thank you. I'll try again this week-end.
But here, my concern is : why should I add my secret key in plaintext ?
Regards.
Xuo.
| [reply] |
Hi,
I need to try reproducing the IPC error after I've simplified my script. I will do that only during the next week-end.
Regards.
Xuo.
| [reply] |