in reply to GPG batch mode, GPG.pm, and win32

Ton,
Thank you for your help.
I'm trying the module that you've posted, but I'm having hard time figuring out which subroutine to use where...
(How can GPG_Decrypt_Asym decrypt if you don't send it a passphrase?)
Could you post some client code too?

Thank you for your time,
Dan

Replies are listed 'Best First'.
Re: Re: GPG batch mode, GPG.pm, and win32
by ton (Friar) on Apr 13, 2001 at 04:12 UTC
    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...

      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/