home *** CD-ROM | disk | FTP | other *** search
/ Der Mediaplex Sampler - Die 6 von Plex / 6_v_plex.zip / 6_v_plex / DISK5 / DOS_10 / PGP23ASR.ZIP / PGPCTB23.ZIP / ELM_NN.ZIP / MOREPGP < prev    next >
Text File  |  1993-03-07  |  1KB  |  42 lines

  1. #!/usr/bin/perl
  2.  
  3. # written by jason steiner, jsteiner@anwsun.phya.utoledo.edu, Jan 1993
  4. #
  5. # if you use or make improvements to this program i would appreciate
  6. # copies of your modifications & your PGP public key.
  7.  
  8. $|=1;
  9. $topgp=0;
  10. $logname = $ENV{'LOGNAME'};
  11. $pager='/usr/local/bin/less -i -n -s -S -c -M';
  12. $pager = $ENV{'PAGER'} if ($ENV{'PAGER'});
  13. umask 077;
  14. open (PAGER, "|$pager") || die "Cannot open pipe to $pager.\n";
  15. print PAGER "\n";
  16. while (<>) {
  17.     if (!$topgp && m/^-----BEGIN PGP .*-----/) {
  18.         $topgp = 1;
  19.         $tmpfile = "/tmp/.pgp.$logname.$$";
  20.         unlink($tmpfile);
  21.         open (TMPFILE, ">$tmpfile") || die "Cannot open $tmpfile for output.\n";
  22.     }
  23.     if (!$topgp) {
  24.         print PAGER;
  25.     } else {
  26.         print TMPFILE $_;
  27.         if (m/^-----END PGP .*-----/) {
  28.             $topgp = 0;
  29.             close TMPFILE;
  30.             open (CLEAR, "pgp -f < $tmpfile |") || die "Cannot open pipe to PGP.\n";
  31.             print PAGER "-----BEGIN PGP DECRYPTED BLOCK-----\n";
  32.             while (<CLEAR>) {
  33.                 print PAGER;
  34.             }
  35.             close CLEAR;
  36.             unlink($tmpfile);
  37.             print PAGER "-----END PGP DECRYPTED BLOCK-----\n";
  38.         }
  39.     }
  40. }
  41. close PAGER;
  42.