php pgp

<?php

 // Using PHP with PGP.
 // (c) Kelv 2000

 $username = "dummy";       // Your username on the server
 $pgp="/usr/local/bin/gpg"; // path to GnuPG

 // Where the encrypted mail comes from. Dummy address from your keyring.
 $from="Example.com website <[email protected]>";

 // The recipient. This is the imported address from your public key.
 $recp="Example orders <[email protected]>";

 // The data to be encrypted
 $data="Text that will be encrypted"; 

 $command = 'echo "'.$data.'" | '.$pgp.' -a --always-trust --batch "
 $command.= '--no-secmem-warning -e -u "'.$from.'" -r "'.$recp.'"';
 $oldhome = getEnv("HOME");

 putenv("HOME=/home/$username");
 $result = exec($command, $encrypted, $errorcode);
 putenv("HOME=$oldhome");

 $message = implode("\n", $encrypted); 
 // $message now contains the encrypted data.

 $subject="New order from example.com website";
 $header="From: {$from}";

 mail($recp,$subject,$message,$header);

?>

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source