#!/usr/local/bin/perl -w print "Content-type: text/html\n\n"; use lib qw(/home/www/davxw000/data/sitelib); use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use GnuPG::Tie::Encrypt; $s = "This is a test.\nAnd another test."; $m = 'test@test.com'; # registered in gpg key ring $e = &encrypted($s,$m); print "Encrypted:
\n" . $e;
sub encrypted {
my ($plaintext,$recip) = @_;
my $encrypted = "";
tie(*CIPHER,'GnuPG::Tie::Encrypt',armor=>1,recipient=>$recip);
# tie interface. open buffer
print CIPHER $plaintext; # and encrypt into buffer.
$encrypted .= $_ while (); # now read from buffer
close CIPHER; # the encrypted data
untie *CIPHER; # and close buffer
return $encrypted;
}