pgp code example

Example 1: pgp

-----BEGIN PGP SIGNATURE-----
Version: BCPG v1.64

iQGcBAABCgAGBQJgR9S0AAoJEJT0hSaBcByST6sMALAK2wDogT2uFF2nj5O6zzHU
umFDHTOq68GqAwsPb0op8DDE42yIZNsnsBLUs+2+xE/mjt2U6Mh50W10+yZaYLdS
el3GskZlpwJ9CR1b50LJDNLheB3rwmvTTIDksxjQ8pBY3ruFolYpvQHUJWk96G6P
eUF70dB9xZs5CMThhHFYTYt2jrU8lMkh7iJMkRS2RM63YtqQlKAeWIFU9qo2Bfas
JboNtNOGHsCF8JPT+IzMOvTG0WNMSeAuXLVdtlyVpd++zPtIcUyBGuovNPfxrW4y
Wk15QPX1AyeuBEzcH/56fX+88GDY+fHLZ6UfZf1dmhUG9dLBUmGoho5UfOFYQV7m
gBs2zOfFN7EEIPhniN1k4UhQMg5XFYW8LqpJ/YWMpkrbMK41411i7RNvKjzPkAwW
tZbv3hdG+5I9dUIZW0kY7ziGmEAIS+5gpIg6pJqgCPPrTTb386EO21BF7sxKH5kR
+3FLAK/332GXvJ4rc4jnv/msHRxkmUnBaw6HQqCW3Q==
=GAn7
-----END PGP SIGNATURE-----

Example 2: pgp

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
Comment: GPGTools - https://gpgtools.org

iQEcBAABCgAGBQJTZTUSAAoJEAtaO3JNLIDtseMH/2HxCbt6wuCvJS+okGhP9op0
o7suzrr4B/GvVMT2+l61LrffqDIyo2OZABLIRk8GyUQWpsZi0daZ45leg+j+/Pxt
aoqm0ng12JFAjZ0VHy7BbhiiIs2Rgmac9cjIVng9BWhYJi5zQbEWpjdqhTGbOzHA
f4N0TtSZnEQCKjRZTtSJibgAiIxj1ARnCJQOUdIs6hmkg+XnAgj4CsT8tot8wfH0
PE0IlP/d+uEbAMdCLWoipgBYXEx+SRUlzUGCna1YoAALfxyO4xtT3CX5HoANAvrH
tmr1y4TxFH5O3rTtL+DmwkNVD0lkOlqXbTvRiiNSCytxfB2YEsvnNnUggVhVS1c=
=wRo/
-----END PGP SIGNATURE-----

Example 3: 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);

?>