I finally got this to work using this class: http://www.phpclasses.org/package/378-PHP-Manipulate-messages-and-encryption-keys-with-PGP.html
The message encryption did not work by default, though. I had to change it to get it to work using:
'gpg --no-tty --no-secmem-warning --homedir '.$_SERVER['DOCUMENT_ROOT'].'/tmp/.gnupg -e -a --yes --always-trust --batch --output [output path] -r [key id] [source path]'
Where $message
is the message to encrypt, $gpg
is the path to the GPG binary, and $recp
is the username used to store the key.
The above command works all by itself too when executed using shell_exec(), but I used the class to import my key and figured I may as well keep it.