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-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6SJUOs3LppPPTmKrvwHe
3eGIGjhToZ1qJs8YL0P55FT8BujwdK4jh8eGu31rCGRw3N+FIkCwtNN5nheGr/fS
h7JKURRPz77+l1gKCLgXKUe5104K3ZfltLvsLQ2Ax3PsEk6dDqUeNNxb2QUnbzfo
tZKZ6M0nnDk7/TyQRZETvYi6z5lSiKZdIOsbJarlxbQpGx2Oe4gXLC1t+lXkW4dW
6EeD3tFsI29aUXg2PCZ5AWifLXBhVlmUCYFU1Q2BzO//db21+opIYGe6CZ28gnKq
bo63NHRwAwm67xGYZsBFTIl75YDx2PMKrp4Nq3l1CIF1ZZAzQ3+J95AhQKKvAEoY
QQIDAQAB
-----END PUBLIC KEY-----
'
,
  
'rsa' => [
    
'n' => '"T:˦Nb8Sj&/CTt#dž}kdp߅"@y҇JQOϾX
)GN
ݗ崻- sN4[\'o7赒\'9;<EϙR] %Ŵ){,-mU[VGl#oZQx6<&yh-paVY    T uH`g    rn4tp    fEL{
yuue3C!@' 
"\0" 'JA',
    
'e' => '' "\0" '',
    
'd' => 'njQ IUb3<?~AHDv$lr{=O y> ]~أ*$\'btC0G`+jaN A .X)Q FLzĠ~VH="h#{}s6ߏ!z"=WAѸfWb(pi쓜@ GԂf    .,' "\0" 'aw\', P Ӆ\\BRSN.h Dˀ!',
    
'p' => ' \'0mẁ *xى|8"X;
/A*־(Jsɸ5K厏M;hoI`)FC%A..6;U!cQVZ>/%'
,
    
'q' => 'hGe$܂g!;rjq+C| 766}`ટӘ褛TGf [8L)^Ĩԛ ^XA,rmq j=>DC',
    
'dmp1' => 'F<S=C }XbC|۷6;N:Ǜ H
la5SpxrutIf' 
"\0" ' I5IyU߻%s
HtE=D:ieXQ^*'
,
    
'dmq1' => '-z' "\0" '0iLhFSλІ0ui =q
՚ߞߩY.2YO((ϗDÃ0Na0WӼ3
tv뷋h]t\\ 2B>~qY5'
,
    
'iqmp' => ']`i$t02")& a    bγ}M6H)ey`[\'&)r\'Vً_8=gپ"Ko3:Ub',
  ],
  
'type' => 0,
]
$hex = [
  
'n' => 'e922543acdcba693cf4e62abbf01dedde1881a3853a19d6a26cf182f43f9e454fc06e8f074ae2387c786bb7d6b086470dcdf852240b0b4d3799e1786aff7d287b24a51144fcfbefe97580a08b8172947b9d74e0add97e5b4bbec2d0d80c773ec124e9d0ea51e34dc5bd905276f37e8b59299e8cd279c393bfd3c90459113bd88bacf995288a65d20eb1b25aae5c5b4291b1d8e7b88172c2d6dfa55e45b8756e84783ded16c236f5a5178363c267901689f2d7061565994098154d50d81ccefff75bdb5fa8a486067ba099dbc8272aa6e8eb73474700309baef119866c0454c897be580f1d8f30aae9e0dab7975088175659033437f89f7902140a2af004a1841',
  
'e' => '010001',
  
'd' => 'bf6e96e76a510d4955f2b1870162d1d433fb043cb83f7ef8c94148449776bc8d241db06cb202c3de1c727fc5ee7b87ae3d4fb50c793e205d7e01d8a39a1ecedaea05a82a1b9724e7fcf227db1cfeb7c0d3d2fd9c6274f603c043a082f3f9d33047a011cb12be88fd60d6052b6a61e84e20410d2e589629511f11fa0d85a146014ccc7af7c4a0877e02ee56481ba1fbbd3d2216682311ff7b901f87fd7d887336ecdf8f17adaa06217a22063d57b741aaefa716d1b866bd571d629d28d9e0837069ec939cd840ad81910b47d482d866a3f384870999cb2eadaa16122c00cb617727d32c1afccf0b5020ccd3855c8c4252534e9fe6f32ea2e86820f444e7cb8021',
  
'p' => 'f90b2796fa306d0ee98977d7cccd8012200f11fea7b19e2a78a7b8d989eb7cd9389022e0d5078158a69cb83b7f0a2f411d8b0efcb2ecfbbb2a9ac2d6bedc288f4ab073c9b8354b9316d7e58e8fe0de4d3bb8d213b0686f9e9ecd4960948929a6464325df412ea8e5bfda2eb18e1d03b0363b552163ff9751565a3e2fab128325',
  
'q' => 'efa568ee4765b724dc826721af883bb4726a8513fe712b43e51aef7ce80d9ea2c1db153736020fba36d07df0601798e0aa9f1fd398e8a49bcf54af471a1f66f320189eeb5b9138f47f83014c295e05f4c4a87f19d0d49baf999d0c015efdb9eeea58ab0ee59f41bc2ce8726db003d319ce717ff693208c6a3d3ecc0f8a4443ed',
  
'dmp1' => '46d43c533d1eaeb5b207cdd4cb439aec0cc01c7f0f947d8658c062db43d57cb18edbb77fb836a53be04eec3ac79bceeab70b489ce80a6c61c3f135febb53841994c57078eb7204e77574bbadfb0f9a49def5669200f702dfdb0c499535497955f7dfbb12aec825730a4874453d44d53ab581d46965b65883e28a51eb5ebd2a1d',
  
'dmq1' => '1dce2dd1ccf17aa8cc003001818a691a954c6846c7539df4f0cebbd086300375ecb469dc170c84963d710ae8d59ab9b9df9eb0dfa959edf72eff32599e871f4fc7c32828cf97ad44c38330ab1f4e0161a2ffede6f1113057d3bc339d0c0a7490a176ebb78b99961c685d74b5edb95c0d0e9f113242b43ea28c017e71c4599f35',
  
'iqmp' => 'eafeb0abb05d60b39f0604691b2474e2b207ca1ae2e730a7de327fe69b2202b016292614130b6109eae962b5e0ceb3a6ee7d134d87da188a3648296579ebc160c116c65beff4e6a0c5dfc0a8279c972616a1ef89fef2297227b156add98b16fce7155ff198811438b13d6713d9bebb940ec6224b8b6fc60733953a1a8e556293',
]
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