my $mysecring = Crypt::OpenPGP::KeyRing->new(Filename => $CONFIG{privatekey}) or handleError( "Error: ".Crypt::OpenPGP::KeyRing->errstr,1); my $mypubring = Crypt::OpenPGP::KeyRing->new(Filename => $CONFIG{publickey}) or handleError( "Error: ".Crypt::OpenPGP::KeyRing->errstr,1); my $theirpubring = Crypt::OpenPGP::KeyRing->new(Filename => $CONFIG{icskey}) or handleError( "Error: ".Crypt::OpenPGP::KeyRing->errstr,1); my $pgp = Crypt::OpenPGP->new( SecRing=>$mysecring, PubRing=>$theirpubring, ) or handleError( "there was a problem creating constructor\n\n".Crypt::OpenPGP->errstr,1); opendir(DIR, $CONFIG{ToDir}) or handleError( "Unable to open directory $CONFIG{ToDir}: $!",1); my @directory = grep { !(/pgp/) && -f "$CONFIG{ToDir}/$_"} readdir(DIR); closedir(DIR) or handleError( "Unable to close directory $CONFIG{ToDir}: $!",1); print "found ".(scalar @directory)." items\n"; foreach (@directory){ print "encrypting $_\n"; my $encryption=$pgp->encrypt( Filename=>$CONFIG{ToDir}.'/'.$_, SignKeyID=>$keyid, SignPassphrase=>$pass, ) or handleError( "there was a problem encrypting the file\n\n".$pgp->errstr); open FILE,'>'.$CONFIG{ToDir}.'/'.$_.'.pgp'; print FILE $encryption; close FILE; } }