How to generate a Public and Private Key: RSA Examples and Notes from phpseclib

The phpseclib on source forge allows you to generate Public and Private Keys and is fully interoperable with OpenSSL and other standardized cryptography programs and protocols.

Software is written in PHP and designed to be ultra-compatible (working with PHP4+ assuming the use of PHP Compat) and does not require any extensions.

For purposes of speed, mcrypt is used if it’s available as is gmp or bcmath (in that order), but they are not required.

Examples can be generated right from the Webpage.

phpseclib.sourceforge.net