Skip to content

Instantly share code, notes, and snippets.

@nazt
Created March 25, 2010 07:08
Show Gist options
  • Save nazt/343281 to your computer and use it in GitHub Desktop.
Save nazt/343281 to your computer and use it in GitHub Desktop.
<?
// generate a 1024 bit rsa private key, returns a php resource, save to file
$privateKey = openssl_pkey_new(array(
'private_key_bits' => 1024,
'private_key_type' => OPENSSL_KEYTYPE_RSA,
));
openssl_pkey_export_to_file($privateKey, './keys/privatekey', $passphrase);
// get the public key $keyDetails['key'] from the private key;
$keyDetails = openssl_pkey_get_details($privateKey);
file_put_contents('./keys/publickey', $keyDetails['key']);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment