显示文本框

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"]);
}
?>
结果
$resource = 'OpenSSL key ressource'
$array = [
  
'bits' => 2048,
  
'key' => '-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuEKQHZT4oi8JJRxDAWr+
aKN9Yh2LAXsTMRWxbKYcZdWVae0fTHNQmvPv8PwNbun6xd/WDpY9w8Mb2N0+sZhz
O8Hi05hRaJROHL4/BorD6IsAbnXpki0LcD51Vz+KckdOanDBLeNH9kHJ8O9tenW5
uDFH3fK+JNOeABMCRBexezQwKM5mmIXdh73PpwxNtE4Ecwb1JYAJ2qlb2gr1kvlC
UbTN9WDmFOWPq9ZbdsdnqduPrp4JW1bg+iCJ7l7NXtJ+sIUhXmV3trzfg2cQviNI
B+BK7LgrChqmy01b1ZzxW6A9ZXWZkKoXbl9amNaXbdcaHCVkjVuCLEUIUGzHosj6
CQIDAQAB
-----END PUBLIC KEY-----
'
,
  
'rsa' => [
    
'n' => 'B/    %Cjh}b{1leՕiLsP n=>s;ӘQhN?' "\0" 'nu- p>uW?rGNjp-GAmzu1G$Ӟ' "\0" 'D{40(f݇ϧ MNs%    ک[
BQ`叫[vgۏ    [V ^^~!^ew߃g#HJ+
M[՜[=eun_Z֗m%d[,EPlǢ    '
,
    
'e' => '' "\0" '',
    
'd' => '<rm^PgDR@
d`];.{ǧKYo>j CR;P^Q/cA2Qvl_GgvbɺT,zRq' 
"\0" '6>3-͝"i/&߃v^ʳڙ =\\JuZ"q7DџG.g\'*aɼ @IFfYUw9aeR_VwL0' "\0" 'BCouM/̆R',
    
'p' => 'Ĺ2((xYI;(\\j`Epd' "\0" '|$:":w|$5h ,Fա\'Kd9p9Ew&pQ9h)n)vt_Ƶ2w{,ն3ȹ8',
    
'q' => 'Ɩ-K6N,=6$3sƞ(We]ͪf6V7%J\'b-\\2ˎq,>PԮAL¶' "\0" 'iEH<<-+fql!{s5ƝծfU    ',
    
'dmp1' => '䟼PJƐFg6$QVDT|^O堦g;{xzI}) ,Xτe۷ޒ1wuIq>8No,p,;' "\0" '',
    
'dmq1' => 'R~,X_ŷ#iBZJ=ӊ)BWJm[.uWVׅLJ#"f5YwaE~,
J ?_GH Qr~7eB+7\''
,
    
'iqmp' => 'ˎW`=$)xvsE;%gn\\F@/3ICޭ㱞Uf7L5w|i[Pw@>4$A7
TEx`3ljQS:@imV'
,
  ],
  
'type' => 0,
]
$hex = [
  
'n' => 'b842901d94f8a22f09251c43016afe68a37d621d8b017b133115b16ca61c65d59569ed1f4c73509af3eff0fc0d6ee9fac5dfd60e963dc3c31bd8dd3eb198733bc1e2d3985168944e1cbe3f068ac3e88b006e75e9922d0b703e75573f8a72474e6a70c12de347f641c9f0ef6d7a75b9b83147ddf2be24d39e0013024417b17b343028ce669885dd87bdcfa70c4db44e047306f5258009daa95bda0af592f94251b4cdf560e614e58fabd65b76c767a9db8fae9e095b56e0fa2089ee5ecd5ed27eb085215e6577b6bcdf836710be234807e04aecb82b0a1aa6cb4d5bd59cf15ba03d65759990aa176e5f5a98d6976dd71a1c25648d5b822c4508506cc7a2c8fa09',
  
'e' => '010001',
  
'd' => '893caa721dfe816d5ef650f2671ff594a21044ff9404ea5205010f40c907e5a10ac3f66495605deccb3b2ed5cc7b8bb1c7a74b9b59b36f16e6aac33e6ab00d43b8c8e4a85219fe3b9f94e304505e51d915dd2fdd638e4132bc925105766c5f47bc6776ba62c9ba548dbff1d42c9d7a5202027100d7363e97339ef4d51a808a2db3cd9d220e692f26df8376b45ef1cab3da9905f10c3debe516d61e5cc54a75f5c85a2298da713744f51cd19f47b5b8b92e1167a307c7272affa9aaf5ce169eb061c9bc8820170540e3cc49a6bb460fb5b266595577b7803961026552b88ed1fb5fc3e3815677dcebb1dec217f14cf23099009942a0436f754d2fcc861e52e001',
  
'p' => 'ed8712c4b9f7a53228a3a028b8781859493b9b28f0f104d75c6ab0a8b560459de01570648797d4007c9506243ab588a4221f3aa816777c2435b2986898e40cbc162c46d5a127eb4ba6cfec936485b639bee315dbea703945db7726fce670513968b0296e29d17674b5dc5fc6b532771f9d7bfe2cd5b6b633e1b1c8b938ecbd01',
  
'q' => 'c696fcb02dd64b36f0b04e2cb48610ed3d11a5bff63624337307c69e28aef9f957655dcdaa66113656bf9137250e99b8f48af94a2762ef2d5c9532adc2cb8e71faf115032c3e5006cad4ae0492814104b9f08ea74c179ac2b60016919b69ada4fb1a45483c9c3c2d162b6671fb6c21aa16afae7be9997335c69dd5ae66b55509',
  
'dmp1' => 'a9cae49fbc504ac690466736b4a724c0ae98ed5156eaf38aff8544c354e47cdf5e4ff507e7e5a0a6b867cefc16fbadb1a6b2ac3b7bd3ede9f478b67a0ed0f6497d9029128d20fc12182c89f0d2eac258851bcf846511d3df1c0310dbb7de923177a475f949eb71c1fc3e8c387f4e93d905ba9cf76fce2c70e9e52c973b1a0001',
  
'dmq1' => '521d7eb0eed32c58b45f8283b3c5b7dc112369f11d42b7e75a4a3dd38a29080e1518421857bc4aa3b86d1003c85be82e7557bdcaeecc56efdfd7859419f7079893d5fa054cd71b4a23b69b9a226635d7597761d5457e812cc00afb4a0c043f9bf7849e5f4748a70d519c7288f1187e3711986542b18e14f8887f1d2b372705d9',
  
'iqmp' => '90cb8e8e5784eea3998c1460e93d2429787604c373453b9bf11a93259b67ac6e5c4689c140c1d22f33494388deade3b19edd55fcdef86637ffb8934c35c777d4c4e47c02b469f25b509e77f9fe40b9db15da3e89c50434bf244137c40a915445780611dc6033ecb06cd76aa2b951e5e4985306c93ac2e7406996c71d6db556b7',
]
示例
#1 openssl_pkey_new  ()
#2 openssl_pkey_new  (["digest_alg" => "sha512""private_key_bits" => 4096"private_key_type" => OPENSSL_KEYTYPE_RSA])
另请参阅
array_map, openssl_pkey_get_details