There is a PHP extension port of the gnupg PGP library. However, I’m having a hard time finding examples that explain how to use the library.
How do you properly create keys for application users, and then use them to encrypt/decrypt text using the GnuPG library?
See this URL it is very help full to you. Download example and try it.
https://github.com/singpolyma/openpgp-php
Or Try it:-
You can download lib/openpgp.php and lib/openpgp_crypt_rsa.php files in above the URL.
examples/keygen.php
examples/sign.php
examples/verify.php