Hi there Monks!
I am trying to encrypt a file using Crypt::OpenPGP, when it runs it does not give me any errors, it just hangs there. Can any one take a look at my code and see where I am missing something.
#!/usr/bin/perl
use strict;
use warnings;
use File::Basename;
use Crypt::OpenPGP;
my $ring = Crypt::OpenPGP::KeyRing->new(
Data => qq^-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.8 (SunOS)
mQGiBFDr.....
-----END PGP PUBLIC KEY BLOCK-----^ );
my $datafile = "original.csv";
# Get just name of the original file to name the new encrypted file.
my ( $encrypted ) = fileparse( $datafile, "\.[^.]*" ); # $name, $path,
+ $suffix
open( INFILE, "< $datafile" ) or die "Could not open csv file - $!";
my $plaintext = <INFILE>;
close INFILE; $ring->read;
my $kb = $ring->find_keyblock_by_index(0);
my $cert = $kb->encrypting_key;
my $pgp = Crypt::OpenPGP->new( Compat => 'GnuPG' );
my $ct = $pgp->encrypt( Key => $cert, Data => $plaintext, Armour => 1
+) or die "ERROR: " . $pgp->errstr;
open( OUTFILE, "> $encrypted.pgp" ) or die "Could not open file for en
+crypted data - $!";
print OUTFILE $ct;
close OUTFILE;
Thanks for looking!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.