Could anyone help me figure out how to use this module? I don't have a good understanding of OO, FYI...(Yes, I have read the tutorial on it here, no I still don't get it.)

I put together this sample script to try and simply decrypt an encrypted file that I have already created:

#!/usr/bin/perl -w # A simple example use IO::Handle; use GnuPG::Interface; use IO::File; # settting up the situation my $gnupg = GnuPG::Interface->new(); $gnupg->options->hash_init( armor => 1, homedir => '/root' ); # Note you can set the recipients even if you aren't encrypting! $gnupg->options->push_recipients( 'ftobin@uiuc.edu' ); $gnupg->options->meta_interactive( 0 ); # This time we'll catch the standard error for our perusing # as well as passing in the passphrase manually # as well as the status information given by GnuPG my ( $input, $output, $error, $passphrase_fh, $status_fh ) = ( IO::Handle->new(), IO::Handle->new(), IO::Handle->new(), IO::Handle->new(), IO::Handle->new(), ); my $handles = GnuPG::Handles->new( stdin => $input, stdout => $output, stderr => $error, passphrase => $passphrase_fh, status => $status_fh, ); # this time we'll also demonstrate decrypting # a file written to disk # Make sure you "use IO::File" if you use this module! my $cipher_file = IO::File->new( 'encrypted.gpg' ); # this sets up the communication my $pid = $gnupg->decrypt( handles => $handles ); # This passes in the passphrase #print $passphrase_fh $passphrase; print $passphrase_fh ""; close $passphrase_fh; # this passes in the plaintext #print $input $_ while <$cipher_file>; print $input $_ while <>; # this closes the communication channel, # indicating we are done close $input; #close $cipher_file; print "$pid"; my @plaintext = <$output>; # reading the output my @error_output = <$error>; # reading the error my @status_info = <$status_fh>; # read the status info # clean up... close $output; close $error; close $status_fh; waitpid $pid, 1; # clean up the finished GnuPG process

I was just trying ./test.pl < etest.txt.asc and all it does is print out the pid. How do I get it to decrypt the file? Either to console or an output file would be fine.

~~

naChoZ

edited: Thu May 29 21:20:36 2003 by jeffa - removed blockquotes, removed leading whitespace in code


In reply to GnuPG::Interface by naChoZ

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.