php pgp

Solutions on MaxInterview for php pgp by the best coders in the world

showing results for - "php pgp"
Filippo
11 Sep 2016
1<?php
2
3 // Using PHP with PGP.
4 // (c) Kelv 2000
5
6 $username = "dummy";       // Your username on the server
7 $pgp="/usr/local/bin/gpg"; // path to GnuPG
8
9 // Where the encrypted mail comes from. Dummy address from your keyring.
10 $from="Example.com website <website@example.com>";
11
12 // The recipient. This is the imported address from your public key.
13 $recp="Example orders <orders@example.com>";
14
15 // The data to be encrypted
16 $data="Text that will be encrypted"; 
17
18 $command = 'echo "'.$data.'" | '.$pgp.' -a --always-trust --batch "
19 $command.= '--no-secmem-warning -e -u "'.$from.'" -r "'.$recp.'"';
20 $oldhome = getEnv("HOME");
21
22 putenv("HOME=/home/$username");
23 $result = exec($command, $encrypted, $errorcode);
24 putenv("HOME=$oldhome");
25
26 $message = implode("\n", $encrypted); 
27 // $message now contains the encrypted data.
28
29 $subject="New order from example.com website";
30 $header="From: {$from}";
31
32 mail($recp,$subject,$message,$header);
33
34?>
35