in reply to Re: GPG batch mode, GPG.pm, and win32
in thread GPG batch mode, GPG.pm, and win32

Oddly enough, GPG asymmetric decryption doesn't need a username... it somehow knows which one to use. Here's some code ('Ton' is a public/private key that I had previously added to GPG's keyring. UPDATE: 'Ton' also does not have a passphrase.):
use GPGWrapper; use strict; my $data = "Hello World!\n"; my $user = "Ton"; print $data; $data = GPG_Encrypt_Asym($user, $data); print $data; $data = GPG_Decrypt_Asym($data); print "\n$data\n"; $data = GPG_Encrypt('dumb password', $data); print $data; $data = GPG_Decrypt('dumb password', $data); print "\n$data\n";
The code assumes that you have the GPG executable in the system path. If it isn't, you'll have to put the path in the open2 statements. Hope this helps...

-Ton
-----
Be bloody, bold, and resolute; laugh to scorn
The power of man...

Replies are listed 'Best First'.
Re: Re: Re: GPG batch mode, GPG.pm, and win32
by isotope (Deacon) on Apr 14, 2001 at 01:41 UTC
    In asymmetric decryption, the key ID of the intended recipient's key is contained in the encrypted stream, so GnuPG automatically chooses that key for the decryption. dvf5907's question, though, is how do you pass the key passphrase to GnuPG since the only parameter to GPG_Decrypt_Asym is the encrypted datastream?

    From your code, I can only assume that your private key is not itself encrypted with a passphrase, otherwise, GnuPG would require that passphrase to decrypt the key to decrypt the data.

    --isotope
    http://www.skylab.org/~isotope/