jaf0faj has asked for the wisdom of the Perl Monks concerning the following question:
Been trying to get a CGI to decrypt an encoded, armored string sent via a post. If the string is saved to the file (say) 'file.txt' then "gpg --decrypt file.txt" from the bash shell will successfully decrypt the file, once I use the passphase 'abc123!' for the passphrase to the secret key.
However, if I try to decode this in the CGI script itself using Crypt::OpenPGP, I cannot get it to work. I've modified the code until the cows come home and most of the time I get the same error message "Symkey decrypt failed: Invalid secret key ID". Here's the relevant code snippet:
use Crypt::OpenPGP; use CGI; my $pgp = Crypt::OpenPGP->new(Compat => 'GnuPG'); my $cur=CGI->new(); my $phrase=$cur->param('phrase'); my ($plaintext,$valid,$sig)=$pgp->decrypt(Data => $phrase, Passphrase +=> "abc123!"); print "[message: $plaintext<br>valid: $valid<br>signature: $sig<br>err +or: ".$pgp->errstr."]<br><br>\n";
The last print statement returns the following:
message:
valid:
signature:
error: Symkey decrypt failed: Invalid secret key ID
And yet, if I dump the contents of the variable $phrase to the file file.txt and do gpg --decrypt file.txt from bash with passphrase abc123! to unlock the secret key it will successfully decode.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Need help decoding string in Crypt::OpenPGP
by BrowserUk (Patriarch) on Mar 10, 2012 at 17:47 UTC | |
by Eliya (Vicar) on Mar 10, 2012 at 17:58 UTC | |
by jaf0faj (Novice) on Mar 11, 2012 at 00:41 UTC | |
Re: Can't decode string in Crypt::OpenPGP
by zwon (Abbot) on Mar 11, 2012 at 05:51 UTC | |
by jaf0faj (Novice) on Mar 11, 2012 at 14:30 UTC | |
Re: Need help decoding string in Crypt::OpenPGP
by jaf0faj (Novice) on Mar 17, 2012 at 15:53 UTC | |
by Anonymous Monk on Jul 24, 2012 at 20:30 UTC |