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-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsKVT8Jcv8RBwydEbG50h
47w+lb3GO02ZjRGE9C2rFyhu3hwWg7Yg3/eZ3QG3chu3zga23LIzucFsnq62baWL
6SzFigFnJ+KlZvpmnthCMC0oND4KMgTw/qYfg0V6sJH3mlFLXqj9BEDmG+OnbD/i
avYtalJ8WR7/c+xivUcZvbLp8r7qqk6X5sMNKifIiSWOveeTqrJnLeVLe5CEajyg
fwgKoyzI58Ba8Ryem7Yp/w+khvGkUbbP9jfsuNWAERvK6L3kcQyvVP0/YiQOBFWH
62dm0DvZV9QTiVJUs9Oax45jvfOHEkRj/IIY2eFJ/Hd4GfGe6pOh0SH2cOR1us5t
AwIDAQAB
-----END PUBLIC KEY-----
'
,
  
'rsa' => [
    
'n' => 'S/p!>;M-(n rܲ3lm,Ŋg\'ffB0-(4>
2EzQK^@l?j-jR|YsbGN *\'ȉ%瓪g-K{j<
,Z)Q7Հq T?b$Ugf;WRTӚǎcDcIwxꓡ!pum'
,
    
'e' => '' "\0" '',
    
'd' => '@tBّ{;b?du0l+Poms(lFz)弄F39pq!/l;]~heMd= 0}s3 DRKFn3dv͇`!Z)4B׃Xi! @\\itv61Q&C)1iTwe_q?M98kveݺ#P91DbyC|l@\\D(<UFgl Q',
    
'p' => ' >\\Dnkdme]nBsst)\'FT ~74!6    GaJHx%o:zFk*a<ޏ]vGsfٜ' "\0" '>@{K[@o',
    
'q' => '|?ٌѥU$SKB-ŧH ]#kiWqPږѿ?4N%ppq!AZtY8L.gp1
-]lK88RCaRMUf4k'
,
    
'dmp1' => '-;rȥn    H05{i    w8vf<68    [Xe64Ӆִ@6v-±)Eyy=h$/_ QX3۞i',
    
'dmq1' => 'Qe ,^^6񒝘_},kӋ|pX~ĜV(_!6\'Sߓ#j' "\0" '
CXm `L,,y̡n:]Aњ{ob/f)8"j;莩euecC'
,
    
'iqmp' => 'Ki1w5cOWPS!&}*8d$HN?p#Ҡ!MIQ[h. S愍Xt>xnӃPuS@Ad2\\`Y|cI=$ i䮪mT',
  ],
  
'type' => 0,
]
$hex = [
  
'n' => 'b0a553f0972ff11070c9d11b1b9d21e3bc3e95bdc63b4d998d1184f42dab17286ede1c1683b620dff799dd01b7721bb7ce06b6dcb233b9c16c9eaeb66da58be92cc58a016727e2a566fa669ed842302d28343e0a3204f0fea61f83457ab091f79a514b5ea8fd0440e61be3a76c3fe26af62d6a527c591eff73ec62bd4719bdb2e9f2beeaaa4e97e6c30d2a27c889258ebde793aab2672de54b7b90846a3ca07f080aa32cc8e7c05af11c9e9bb629ff0fa486f1a451b6cff637ecb8d580111bcae8bde4710caf54fd3f62240e045587eb6766d03bd957d413895254b3d39ac78e63bdf387124463fc8218d9e149fc777819f19eea93a1d121f670e475bace6d03',
  
'e' => '010001',
  
'd' => '407442d991c0db7bfd3b968206a4621e3facb264a975300e6c2bcd506f6d7328bcb36c9a467ae929efa583bfc198f04633f5bd39700871aa03212f6cbf3b5d7eba6865bfb74d1564f6db3d208e96300ffa107de6a873a71fb3abe1f1332044528d4b466e06c933891ead6476cd87cdeceb608ce006215aaf2934429effd783a0ae5869c9c821e4a3e592201a7f40055c10dfd269b27476cf36319e90512643fa8c293169b4fa15b018ed8754b87765fc5f713fb24d39f21638aa6b760765ddbaf423a9b5503903c131a8f77f1d95e444b3621edbfc02c179be17e986c443907c936c40805cf9442891bd3c55468eeae11a89cb67b56c0c0fa582f1ded2f6bd51',
  
'p' => 'e00c3e5cd6e102ab93a2446e7f85999d6bfc64ea6dd11365995d6e42969305019073738b7429274680071acf54120d7e1c37aabef23421968d36120947a2edfffc614a8706487816256f3a81f6eee37a1f466b822a99821cb9f38c61bc9d3c91de8fd914155d76477366c3ddd99cfc00da3e407bc54b5bc5e6ee06b6406fc7c9',
  
'q' => 'c9d67c3f91d98cd1a5fdbcb455e312071d24534b422d06c5a7f048ed0da05dfff7236bef699f577150da96d1bfb0b1f83f34bf4e25fcc097b67097f48470bc71ee19a121415a749b9759e038c34c2e1391db67a0190ff1b770310ac5e1e8bbf0e7e02dd1ca5d90b06c4bb2b438387fbcb0d652a6c3ef436108524d5566348c6b',
  
'dmp1' => '872d3bef1dc272aefc8b19c8a56e0109e6de4830dd031935e27b698c097738bd01df76663c369c38c004095beff85865af36b2f13406da0110bfffcfd385ed1cd6b4089840e53676fe2d06dae516aaeec2b1e5298af445797984053deee3db689324ad2f9dd85f05ab0de4bd148fcfc7dfe551589be7e4be199fa13312db9e69',
  
'dmq1' => '516512b41c202c5ebb5ee9039c8336d8f1929d9882f65f7dc42ced6bd38bf17c70f0b2ed589dee887effb7c49c56285f21362753df93df230f6ab68ce0000aaeb34358ac6d8b89ecd90b6095e3844c2c8e2c79cca16ec19ea53ad1ca5d411ad19ae0d7f97b6f621313892f66e82938b2226a3be88ea96575b30265b763c11b43',
  
'iqmp' => '854b69dfe131773511d8634f81b457d27f04dc50d55321a4a026c47da2052a38d2642448a1af189807f69ef24ee93f867023f9c6f5d2a0af21f64d491b51b05bf7a4e568f7f02e0dd05398e6848da35874143e78b96ed38350d175a8c353404164dce4b732f1185c60597cd663493d8d2414fe201adfdd69e4aeaaeb6d54ac82',
]
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