############################################################ # PGP-LIB.PL # # Summary: PGP stands for Pretty Good Privacy and it # is a utility on the internet that allows you to encrypt # and decrypt files. This library interfaces with this # 3rd party encryption program # # This script was written by Gunther Birznieks. # Date Created: 11-5-96 # Date Last Modified: 11-25-96 # Date last modified (mutilated?) a bit more by Peter Gillett # (peter@tallwomensclothing.com) to make it work on a virtual web server # running under NT (Microsoft-IIS/4.0) using PGP for dos (Version: 2.6.3in) # # It may be crude, but it works for me. PG. :-) # # Copyright Info: This library was written by Gunther Birznieks # (birzniek@hlsun.redcross.org) having been inspired by countless # other Perl authors. Feel free to copy, cite, reference, sample, # borrow, resell or plagiarize the contents. However, if you don't # mind, please let me know where it goes so that I can at least # watch and take part in the development of the memes. Information # wants to be free, support public domain freware. Donations are # appreciated and will be spent on further upgrades and other public # domain scripts. # # Purpose: Provides a set of library routines to interface with # PGP to create an encrypted buffer # # MAIN PROCEDURE: # make_pgp_file - makes a pgp encrypted file and sends its # contents back to the user # # Special Notes: Script ties into the pgp executable whose # location is specified in the variables below. # # VARIABLES: # $pgp_path = path to PGP executable # $pgp_options = command line options to the PGP program # $pgp_public_key_user_id = which key to use for encrypting # $pgp_config_files = path where configuration files are located # ############################################################ $pgp_path = "e:\\InetPub\\vs210015\\cgi-bin\\pgp.exe"; $pgp_options = "-eat +VERBOSE=0"; ### note ### do not use the -f option $pgp_public_key_user_id = "pgillett\@ozemail.com.au"; $pgp_config_files = "e:\\InetPub\\vs210015\\pgp"; sub make_pgp_file { local($output_text, $output_file) = @_; local($pgp_output); $ENV{"PGPPATH"} = $pgp_config_files; ## # # the $text_of_cart (or $output_text) is read into the pgp temp file (or $output_file) # ## open (PGPCOMMAND, ">$output_file"); print PGPCOMMAND $output_text; close (PGPCOMMAND); ## # # for some reason, the NT virtual web server I am using does not allow perl to re-direct output :-( # so the original commands used ... # $pgp_command = "$pgp_path $pgp_options "; # $pgp_command .= "$pgp_public_key_user_id "; # $pgp_command .= ">$output_file"; <----------------this is where it was failing on my webserver # # (the symptoms were a blank email message was being sent) # # open (PGPCOMMAND, "|$pgp_command"); # print PGPCOMMAND $output_text; # close (PGPCOMMAND); # # ... I don't know if it is 'cos I am using a dos version of pgp (Version: 2.6.3in for DOS) # or some other reason, but it doesn't work. To prove it was the command failing, and not some # other problem, I changed the open command # # # open (PGPCOMMAND, "|$pgp_command"); to just open the output file the original piped # command was trying to create and write to... # # open (PGPCOMMAND, ">$output_file"); # # # If successfull, this test should send you an unencypted email with all the order details. # # # I can make pgp.exe work in a dos window on my local PC (running NT), but I do not have # command line access to the remote NT webserver. So I copied pgp.exe to an executable # directory (being careful about using double slashes like e:\\xxxx\\yyyy\\pgp.exe) # and tried this system command..... # ## system("$pgp_path", "$pgp_options", "$output_file", "$pgp_public_key_user_id"); # ..... which worked! :-) ## # # this command produces a file the same as your temp pgp file ($output_file), but with an ASC extension. # So we need to strip off the last 3 characters and replace them with asc # ## $length = length($output_file); $newfile = substr($output_file,0,$length-3)."asc"; # # The resulting .asc output file (from the system command)is opened, # read into $pgp_output and closed. # open(PGPOUTPUT, $newfile); while () { $pgp_output .= $_; } close (PGPOUTPUT); # we remove both the temporary files unlink($output_file); unlink($newfile); # we return PGP output return($pgp_output); } # End of make_pgp_file # We always return TRUE from requiring # a library file (1;) 1;