# {{{ encrypt my $encrypted_file = IO::File->new( ">$gpgmpw" ) || die "\n\nUnable to open encrypted master.passwd file. $!\n"; my $mpw_file = IO::File->new( "<$mpw" ) || die "\n\nUnable to open master.passwd file. $!\n"; my $gnupg = GnuPG::Interface->new(); $gnupg->options->hash_init( armor => 1, homedir => '/root/.gnupg' ); $gnupg->options->push_recipients( 'root@propane.gwi' ); $gnupg->options->meta_interactive( 0 ); #my @original_plaintext = <$mpw_file>; ##my $passphrase = "Three Little Pigs"; # We'll let the standard error of GnuPG pass through # to our own standard error, by not creating # a stderr-part of the $handles object. my ( $input, $output, $error, $status_fh ) = ( IO::Handle->new(), IO::Handle->new(), IO::Handle->new(), IO::Handle->new() ); my $handles = GnuPG::Handles->new( stdin => $mpw_file, stdout => $output, stderr => $error, status => $status_fh ); # This is necessary for reading stdin handle from an open file $handles->options( 'stdin' )->{direct} = 1; # this sets up the communication # Note that the recipients were specified earlier # in the 'options' data member of the $gnupg object. my $pid = $gnupg->encrypt( handles => $handles ); # this closes the communication channel, # indicating we are done my @ciphertext = <$output>; # reading the output my @status_info = <$status_fh>; # reading the status info my @error_output = <$error>; # reading the error print $encrypted_file @ciphertext; print @status_info if $opt_v; # only if verbose print @error_output if $opt_v; # only if verbose close $mpw_file; close $output; close $status_fh; close $error; close $encrypted_file; waitpid $pid, 0; # clean up the finished GnuPG process # }}} } } # }}}