I will give you a formal answer, since you have an overly nonspecific request:
file_put_contents("/tmp/document", $text); exec("gpg --clearsign /tmp/document"); $signed_text = file_get_contents("/tmp/document.asc");
Usually you also want to add the --keyring . For more complex operations, you can use the PHP extension for GPG, as shown in this article: http://devzone.zend.com/article/3753
mario source share