Hi Jason, Forgive me if I misunderstand your goal here but I think what you want is to take a file on your system such as testfile.txt and encrypt it with the script owners key and then later ftp this file out. To do this you don't need the private key that is only used to decrypt the data not encrypt it. Remember private keys always stay private, they are never shared.
So take the public key of the user that will be receiving the data and add it to the keyring for the account that will do the encrypting. Now in your script define the file location that you want to encrypt, maybe something like $data = '/home/user/testfile.txt'; You could obviously programmatically define this file if you wished but for this example we will just hard code the file. Now simply encrypt that data with your public key like this my @encrypted = $gpg->encrypt ('$data', '[EMAIL PROTECTED]'); Now you have your data encrypted with the public key of the user that will receive the data. [EMAIL PROTECTED] if you are not sure what the key name is I think you run gpg --list-keys but to be honest I am not on a system right now with perl or gpg loaded but I have done something similar to this in the past. To see the data encrypted simply print out the array @encrypted to screen or back to a file. Hope this helps, -angus -----Original Message----- From: Jason Balicki [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 23, 2006 8:31 AM To: beginners@perl.org Subject: GnuPG module help? I'm trying to do public key encryption on a file so that I can ftp it to a server later. I have a very small, simple script: use GnuPG; use strict; use warnings; my $secret= "thisisatest"; my $recipient = "[EMAIL PROTECTED]"; my $gpg = new GnuPG(); $gpg->encrypt ( plaintext => "testfile.txt", output => "testfile.gpg", recipient => $recipient, passphrase => $secret, armor => 1 ); where $secret is the passphrase for the script owners private key and $recipient is the address of the user I'm sending to, and their public key has been imported into the script owners public keyring. I fully understand the security implications of keeping the passphrase in a variable in the script, and the production version will use a different, more secure method. The file "testfile.txt" contains the text: This is unencrypted text. However, whenever I run the script testfile.gpg is created -- but it is empty. I don't know where to go from here. I've tried using other PK encryption modules, but this is the only one I could get to compile and install. I get no error messages (btw, if you get a bareword failure with the GnuPG module, you need to change the line: my $max_fd = POSIX::sysconf( POSIX::_SC_OPEN_MAX ) || 256; to my $max_fd = POSIX::sysconf( POSIX::_SC_OPEN_MAX() ) || 256; in your GnuPG.pm file, which might be located in site_perl,) and without error messages I'm stumped as to what I've done wrong. I'm testing on a WBEL 3 Linux box, if that matters. Yes, I know, switch to Centos -- someday. :) But for now, this is what this needs to run on. I've tried encrypting other files, I've tried using absolute paths and I've tried various iterations of the options in the encrypt function. But, ultimately, I've go no idea what I'm doing. Any ideas? Pointers? Thanks, --J(K) PS: the ultimate goal here is to allow a user to upload a pdf or tiff file to a web server, change the name to a conforming name, zip the file, encrypt the file and finally ftp it to the destination. Everything but the encryption is working. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>