wrong response from gnupg (expected SHM_INFO): at ./pchat line (I marked the line below) #### #!/usr/bin/env perl use warnings; use strict; use Term::ReadKey; # For the noecho use GnuPG qw( :algo ); # From the GnuPG CPAN page if( $ARGV != 2 ) { die "Usage: pchat "; } client( $ARGV[0], $ARGV[1] ); sub client { my $target = shift; my $port = shift; print "Who do I encrypt to: "; my $keyname = ; chomp( $keyname ); ReadMode('noecho'); print "PGP Key passphrase (not echoed): "; my $passphrase = ; chomp $passphrase; print "\n"; # The user's return key won't be echoed ReadMode(0); # Reset term status open (my $net, "|-", "nc $target $port") or die "Can't open netcat!"; while( 0 == 0 ) { my $message = encrypt( $keyname, $passphrase ); last if $message eq "exit"; print $message . "\n"; # Here's where I'm _going_ to send the message via netcat. # I haven't done it yet, I want to just get the encryption working first. } close $net; print "Connection Terminated.\n"; } sub encrypt { my $gpg = new GnuPG() or die "Cannot open gpg!"; my $keyname = shift; my $passphrase = shift; print "Message: "; my $message = ; chomp( $message ); return "exit" if( length($message) == 0 ); # Quit if blank message $message . "\n" . chr(04); # Tack on a return and EOF, so this looks like a file to GPG my $encrypted_message = ""; $gpg->encrypt( recipient => $keyname, plaintext => \$message, output => \$encrypted_message, sign => 1, passphrase => $passphrase, armor => 1 ) or die "Error encrypting: $!"; # The above is the line I'm getting errors on. return $encrypted_message; }