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-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuwDVKApowgSt3Je2ZUp8
i/CcHCi42XPZAvKumFcvcSHrwUXEVlie1PBVxkO5mtmysH3IEaqevECyUCCYz60+
XaVa8oa9lIrgqJz50oJXfMz9X8Eba5fjbYK51AidXmzrdgmx/GtluiR19w219BVO
oHlkcCSWrLhwNvaFnkfdMeNmyzmeEbiWgXB8tf5gDFkY1PtZqMM0PYEwCXa4AgFm
dY+iqRzLXvCMBK0heGE9uhcqgOzFGwpD/BHcu5naE5rYzwzNsHAqVnUBK0f7Dn9W
K80qREiY1FXkBh2YT4rKjfg7bekdEz56b77s3iPBWWkRUNB9Pg3MLD5UhW6KEWT/
/QIDAQAB
-----END PUBLIC KEY-----
'
,
  
'rsa' => [
    
'n' => '' "\0" '(
hܗeJ|(sW/q!EVXUCٲ}@P ϭ>]Z򆽔ਜ҂W|_km^lv    ke$u Nydp$p6G1f9p|` YY4=0    vfu^!xa=*
Cܻ Ͱp*Vu+GV+*DHUOʍ;m>zo#YiP}> ,>Tnd'
,
    
'e' => '' "\0" '',
    
'd' => 'D,\'ͅm#-N߇!G.Udp.m9Fb#>TP!Q#1wILz|Gϥ0fY-? w2}&kO}
oUEd|ÒadqU\'_0-W#l' 
"\0" '+z' "\0" '+Go*Hd{lA(DGn=K}[ZM 1JTEH=oD"9)`' "\0" 'zʊESKȄPXtaн/Mn',
    
'p' => 'ΤF9oQJ{{>Xi8S܍AL_ۅ3=s55ft {1<;14-H(i.{KzO`?Yg=Ox2ҧD2xOoJwѻ.dG>TW |u3',
    
'q' => 'vMDvEqQ4"fq^ 8a#\'0F=]3G$Ti8K  \'.C(x\'?|
[k Z@}eU5B<E&A}'
,
    
'dmp1' => '#_Coѽq.u qU*D5, ncH4(&8@%5 Jq2i:])gQMr\'_a@vϮ+J(b7kҸR)s8ˋ0. ',
    
'dmq1' => 'C|}:AKNl~4٤x?.    [Ƚf&Fb"' "\0" 'U˹ f,1_ÈslDqs]
N=qx#tI;IѬ)'
,
    
'iqmp' => '(۱T.2e    aŐfuajn!X4K>ˍ?}|.R09)4bbGUXU* J6M[eѯSЋΐZŘ}tsO',
  ],
  
'type' => 0,
]
$hex = [
  
'n' => 'bb00d5280a68c204addc97b6654a7c8bf09c1c28b8d973d902f2ae98572f7121ebc145c456589ed4f055c643b99ad9b2b07dc811aa9ebc40b2502098cfad3e5da55af286bd948ae0a89cf9d282577cccfd5fc11b6b97e36d82b9d4089d5e6ceb7609b1fc6b65ba2475f70db5f4154ea07964702496acb87036f6859e47dd31e366cb399e11b89681707cb5fe600c5918d4fb59a8c3343d81300976b8020166758fa2a91ccb5ef08c04ad2178613dba172a80ecc51b0a43fc11dcbb99da139ad8cf0ccdb0702a5675012b47fb0e7f562bcd2a444898d455e4061d984f8aca8df83b6de91d133e7a6fbeecde23c159691150d07d3e0dcc2c3e54856e8a1164fffd',
  
'e' => '010001',
  
'd' => '08442c27fdf5cd85c96db3e3232d1cbe4edf87bb2118b3af471b152eb4c3eb1b55c19064f2702e6d3946816223053e5450caee9a2151acfeab23319dafa877d649e5f04c967ac77cd0d7478fcfa530661b592d3f1a0d77c7327d266b4f118a7d0a15b9a16fd9ea558c45647cc392618c64715527b8e55fadce302d8de69d5784236ce0009188e42bd8e3c27a001ea4a02b47e06f86faa21b8b2a929abe4864df7bf36c41d42844476eaa3dcb4bf10f7ddc0e5b5a4de9f9d90d31aa4a541845ed0e87d748cae5fbeb3dbbd7ccd107ae6f4408c0df22ac391d2960909af2e4198fdfc000997a80ca8a45c8534bc884da505894d874f361ced0bd84d92f144d6ea1',
  
'p' => 'f002cea446396f514a7b7f7b3ead58699c3853dc8d9f41ea4ca85f1ffee0fbdb85333d8ee2733535c302d566e674e60d7ba1d831893ccdbeeb3134d2d52d4828fd692eb17bad4b02d87a4f603f590418673d4f1e86c178f232d2a71bb2443278ad4f6f4a777fe69ed1bb2e64473ef954570b7c8719b303758ba6fa10d833e5d5',
  
'q' => 'c77605944d4480d0cb768845ed71513422669d93b4ba715e0b38fe619682d802dc23952730c146e53d5d33472454690838874ba8c10de714da14a4070d272ec7d07fd943288e781e27013ff27c0a5b016b0c99faa85ad018edbd1d409d7dbee9ebf9dc65e855c51e92a73542e53c8f9f0745d6c21a1e172699e4d7fb41ce7d89',
  
'dmp1' => 'b0235f436fc5f6cbd1bd9071022e75140c71ca19b2558e2a44d7cbf7cf358da02cc0ce0c6e63de48f634be282638e41c40ff258a350d4a7132698a3aaff7eb5d299c6788191bb451024dc0b301ca7216f6ad27c35f61dd40e1cb7697fcdbcfae80822b4a9b2862376bf3d2b80511522973381acb8b30b4f92ee3fbe120c9f581',
  
'dmq1' => '437c7d3ac641ed4bb7ebad03ebe8b14ef06cc3d81c08111f7eb093f134d9a478a33f2ed209befb5bc8bd6602261aa146f4c9622200dfd155cecbb90be1b9662c993108b39e5f45e8fdcd80736ce09c1608c044c0f88171735dcce4bede0a93b3d5f1be4e84a3b0843d9e7178e6d2eccd23cacf74f11d493bf849e381d1ac29f1',
  
'iqmp' => 'a2b2e19c28a2dddbb1e2548ff92e32bd651e0383b0cd09b6fb61ea97c590669d141875ec61ea166ace1c1b6ec5cdfb8c218658a2a8fa34184b8e3e16d8e7891fcb8d8c3f7d16c37c2edb5230399bb29e293462ad62984755589655d02a204a364d5bae6580a7d1af809c830e9953d08bce90fba4c55ac598c27d74734fea1c1a',
]
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