GnuPG (GPG) and mailer PHP class.

Supports:

  • encrypt and decrypt
  • sign and verify
  • mail
  • accept stdin

Download

git clone https://bitbucket.org/21h/phpgnupgsimple.git

Usage

Encryption of stdin example:

<?php 
require "/opt/phpGnupgSimple/gnupgsimple.php"; 
$stdin=""; 
$options=getopt('m:s:'); 
 
while($f = fgets(STDIN)){ 
    $stdin.=$f; 
} 
 
$pubkey=file_get_contents('BORODA.asc'); 
$gpg = new GnupgSimple($pubkey, '', ''); 
$encrypted = $gpg->encrypt($stdin); 
$gpg->mail($options['m'], 'root@blindage.org', $options['s'], $encrypted);  
?>

You can use it to encrypt cron logs:

MAILTO=""
0 1 * * * root /opt/backup.sh|/usr/sbin/php /opt/mailgpg.php -m 21h@blindage.org -s "secret server report"