Perl'ers
I am using gpg within a Perl program to decrypt some data files. In order
to decrypt a passphrase has to be passed to the gpg binary and I choose to
use fileno function but it is hanging waiting on the passphrase. I am
trying to pass the passphrase to the binary via fileno.
Any ideas on how to fix this?
thank you
The equivalent Unix command would be
cat "file_with_passphrase_in_it " | gpg - -passphrase-fd=0 - -decrypt - -
output "decrypted file" "encrypted file"
Here is my Perl code:
use strict;
use warnings;
use diagnostics;
use Net::FTP;
require 5.8.0;
$ENV{"PATH"} = qq(C:\\Perl\\bin:C:\\Program Files\\GNU\\GnuPG\\);
my $p = q/--passphrase-fd=/;
my $de = q/--decrypt/;
my $outp = q/--output/;
my $gpgbinary = qq(C:\\Program Files\\GNU\\GnuPG\\gpg);
my $txtfile = qq(C:\\Program Files\\GNU\\GnuPG\\decrypted);
my $ascfile = qq(C:\\Program Files\\GNU\\GnuPG\\tstfile.asc);
my $pass = qq(C:\\temp\\pass.txt);
open (PASS, "+<$pass") or die "was unable to open FH $!";
system($gpgbinary, $p . fileno(PASS),
$de, $outp, $txtfile, $ascfile);
close (PASS) or warn "was unable to close pass FH $!";
_END_CODE_
_BEGIN_OUTPUT_
Reading passphrase from file descriptor 3 ...
You need a passphrase to unlock the secret key for
user: "derek smith"
2048-bit ELG-E key, ID 985DB557, created 2005-12-30 (main key ID 4A673EF3)
gpg: encrypted with 2048-bit ELG-E key, ID 985DB557, created 2005-12-30
"derek smith"
gpg: public key decryption failed: bad passphrase
gpg: decryption failed: secret key not available
Press any key to continue . . .
Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>