Display the text box

openssl_pkey_new()

« openssl_pkey_get_public | openssl_private_decrypt »
<?php
$resource 
openssl_pkey_new (
    
  // [array $configargs]
);

// shows the key details, plus the rsa, dsa or dh key details in hexadecimal
if ($resource) {
    
$array openssl_pkey_get_details($resource);
    
$hex array_map("bin2hex"$this->result["array"]["rsa"]);
}
?>
Result
$resource = 'OpenSSL key ressource'
$array = [
  
'bits' => 2048,
  
'key' => '-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1MFEWsrv3tgoc1FU3OLW
FSGp9snym1TyuGCCg4Ju7MX0lV1MO0VKg28n7ylhexNHmKFqffWQuJCSljS2bHws
cN9mq7vdIydIdAD6siztPEJD4uwRm0JxmipX441lRYURoySDLFztQ5LnQZ3egAG7
+56llPl9P6VRVK9pnTiZQfKFfO3iYGuZOPH5lrM+sctLUviLeSrfN6FWSGj9WzK4
I2ms78Q9mRffzqThWjxQVHFW7CicMbtYCSeFWloTqrTBfYXppjMXc2e83BlIvU0M
voxcZyvNkfSyyKHzmMQLC2Xt8U38OteLzdG2XEHtELTtymcUneo/0b0naAW3HSD0
LwIDAQAB
-----END PUBLIC KEY-----
'
,
  
'rsa' => [
    
'n' => 'DZ(sQT!T`n]L;EJo\')a{Gj}4l|,pf#\'Ht' "\0" ',<BCBq*WeE$,\\CAހ}?QTi8A|`k8>KRy*7VHh[2#i=ΤZ<PTqV(1X    \'ZZ}3sgHM \\g+͑ȡ eM:׋Ѷ\\Ag?ѽ\'h /',
    
'e' => '' "\0" '',
    
'd' => 'Edfdè:OxZ&    uoҎ_w<I1
ZY+0P\\0"\\HjX޼`' 
"\0" 'fAU+s7gss{B
XQ=oSa>9 Ka
*,L[q?UzexQ7b*sɿ#    <LRFH⨔?Çs]lm HK=' 
"\0" '+]{֪TV?[P4\\l"n2ުv1BuB' "\0" '<o]jh؈',
    
'p' => '
^     M?,u,3;V <U֎V;Sj͒B-!FKhaqK9UЇt^F&eeC!ԔSz庯rc/H'
,
    
'q' => 'cJ2o/-ꏠĠ3n{?B2' "\0" 'ͅؾRD
7ݽkC4Wǯ>l7XT8+nNR' 
"\0" 'Ց#p7bm^E%B19xtiɮHA9(͕٘%',
    
'dmp1' => ',Ǖ̵֔Ơq7c1ȁD|rqW>X=]*Vak5/]RШΒv9 2)B?7y lZ:am]8i',
    
'dmq1' => '<Uf5BJm~[LyޙHϹR똴K.%M~I]ȷ$uTgoPՏ\\$?̘4I
LarZz(*'
,
    
'iqmp' => 'zvh~F"A4 =1mSv}8v
#HY׸x<[^1a53*GM' 
"\0" '-Ӿ ;ٞՑd=`eH\'\\^ݢauhہg˓T3',
  ],
  
'type' => 0,
]
$hex = [
  
'n' => 'd4c1445acaefded828735154dce2d61521a9f6c9f29b54f2b8608283826eecc5f4955d4c3b454a836f27ef29617b134798a16a7df590b890929634b66c7c2c70df66abbbdd2327487400fab22ced3c4243e2ec119b42719a2a57e38d65458511a324832c5ced4392e7419dde8001bbfb9ea594f97d3fa55154af699d389941f2857cede2606b9938f1f996b33eb1cb4b52f88b792adf37a1564868fd5b32b82369acefc43d9917dfcea4e15a3c50547156ec289c31bb580927855a5a13aab4c17d85e9a633177367bcdc1948bd4d0cbe8c5c672bcd91f4b2c8a1f398c40b0b65edf14dfc3ad78bcdd1b65c41ed10b4edca67149dea3fd1bd276805b71d20f42f',
  
'e' => '010001',
  
'd' => '4564c466d8ca64651ccc803aadd14f0295785a86841b261a050975886f82beb7d28ee55f77f5a1d83ce94998b5b2ef16eb31bb0a5a8e59a4ce2b3006505c3022a0bb5c486a588cf794debce660c100669cbde741d6e2552b73a437146773c5737b42ed860ac958c111acd5513d6f53613eddc3399d20a54b61d3d51ef2d70a2af7eaf42cd14c01a6d3c1a8bb025b8be1ae713f557a65a5785137622aa0eb8f73c9bf2309b13c4c52469cc2480fbd0e13afdee2a894d43fdbc3879815cd735d6c9b899d6d0b481e0f4b3d002b5d7bd6aadc54563f815bada895509d34e55cf06ce122b9f0bc6e32b390deaa8112763104dbea427542003c6f5d6abd0368d88801',
  
'p' => 'f6040a96c85ef4940d094d7fd802d8d33f2c1b06752cdf33af11873b560deef13c8055d68efdee5680133bee115392fdaba3aa6ad6d5f9cd92422da51fe8e8c421ba46fd4bc1cd1c681ffedb61714bc73955ab8c0ed08774ce5e4690e826faeb6565ee4321d2d4948c537adbe5baaf85ddfe7285a3fd17c9df632fcf03d848a9',
  
'q' => 'dd63aa4ac30eb7326f2f2da5daea8fa0c4a033d10f6e83c2137b3fa0423200c5cd85bdd8bea152c0440aa43710ddbd6b433457c7af3ecc076c3758cf5438da2b6e4ec9185200d7d59123708df6371af21d621a6da45ec1809fe71845254214318239cddc7874d2698404a910fcb5c9ae489641e8b3398c289fd998cd95e22517',
  
'dmp1' => '2cc79589d694fa1dccb5a9c6a071fc378f631ed43115e6d6c881ff447ca8729ab47183ae573ebf583d5dc2e5d57f89dce49618d9f39ae52a56f9f6c6fca4ef616be6352fbbcf5ddf52d0a81a148583ce929016769ae7b81039d40d32291f9742aba53f16371ce216dbe8020feea3e9790b6c5a3a1b1c616d1c5d38818ce89c69',
  
'dmq1' => '16013c01e655661c1b35034282f9e180c74a6d1c107e999606bdaf5b4c790fde9948fbcfb952eb98b4aaa21bdf0f4b2e882581bc154d16967e491a08b1845d1b0801c8b7241f755482f294d3676f9ebc05f3a450d58f9d881d5ca8eae68324e2aee0f3f73ff9cc9834490a4ce7f161b472fe8c5a86c5e78a7a28f4a92a86a9cd',
  
'iqmp' => 'dc7ab976687e461b2202984134b50b9ff384e9af3df0a70e316da6b6531376b287eca8e40eff7d388ec0760ad9f023485986d7b81f12781e84963c0397d25bf8a05e3111946104803533992a47f04dc1db00e42dbcd3be0ba40d8d91933bd99ed591643d82f36065480727a75c1f5edda2617568db818367cb937f975433a69a',
]
Examples
#1 openssl_pkey_new  ()
#2 openssl_pkey_new  (["digest_alg" => "sha512""private_key_bits" => 4096"private_key_type" => OPENSSL_KEYTYPE_RSA])
See also
array_map, openssl_pkey_get_details