Generate Keys

The following PHP encryption example uses the phpseclib secure communications library.

Generate RSA keys

Generate an RSA private and public key pair:

<?
public function rsa_generate($bits=2048) {
    $rsa = new Crypt_RSA();
    define('CRYPT_RSA_EXPONENT', 65537);
    $keypair = $rsa->createKey($bits);
    return $keypair;
}
?>

User Contributed

LaunchKey links to user contributed code as a resource to its community. LaunchKey does not in any way guarantee or warrant the quality and security of these code bases. User contributed code is supported by the creators. If you do find a link from the site to user contributed code that is malicious or inappropriate in any way, please report that link to LaunchKey immediately and we will investigate the claim. Submit any issue to LaunchKey support at https://launchkey.com./support. ×