package TRIWeb::CCHandler; use strict; use Crypt::OpenPGP; our $VERSION = '$rev$'; our $PUBKEY = './trikey.pub'; sub new { my $class = shift; my $self = { cc_type => '', cc_number => '', cc_name => '', cc_expiry => '', cc_amount => 0, }; return bless $self, $class; } sub cc_set { my $self = shift; $self->{"cc_$_[0]"} = $_[1]; } sub ciphertext { my $self = shift; my $gpg = Crypt::OpenPGP->new or die "Cannot create Crypt::OpenPGP object: $!"; my $ring = Crypt::OpenPGP::KeyRing->new( Recipients => $PUBKEY ) or die "Cannot create keyring."; my $plaintext = <<"EOD"; ---------------------------------------- CC Type: $self->{cc_type} CC Number: $self->{cc_number} CC Name: $self->{cc_name} CC Expiry: $self->{cc_expiry} CC Amount: $self->{cc_amount} ---------------------------------------- EOD my $cipher = $gpg->encrypt( Compat => 'GnuPG', PubRing => $ring, Data => $plaintext, Armour => 1, Recipients => 'doug@tri' ) or die "Cannot encrypt text: " . $gpg->errstr; return $cipher; } 1;