openssl_pkey_get_details— 返回包含密钥详情的数组说明 ¶ openssl_pkey_get_details(OpenSSLAsymmetricKey $key): array|false 该函数返回密钥详情(位长度,密钥,类型)。 参数 ¶ key 持有密钥的资源。 返回值 ¶ 成功时返回包含密钥详情的数组,失败时返回 false。 返回的数组中包含了如下索引: bits (位数...
openssl_pkey_get_details(resource$key):array This function returns the key details (bits, key, type). Parameters key Resource holding the key. Return Values Returns an array with the key details in success orfalsein failure. Returned array has indexesbits(number of bits),key(string representati...
arrayopenssl_pkey_get_details(resource $key) 该函数返回关键细节(位,键,类型)。 参数 key 持有钥匙的资源。 返回值 以成功或FALSE失败的形式返回包含关键细节的数组。返回的数组的索引位(比特数),密钥(公共密钥的字符串表示)和类型(这是一个关键的类型OPENSSL_KEYTYPE_RSA,OPENSSL_KEYTYPE_DSA,OPENSSL_KEYTYPE...
<?php // 创建一个新的公钥/私钥对 $privateKey = openssl_pkey_new(array( "digest_alg" => "sha512", "private_key_bits" => 4096, "private_key_type" => OPENSSL_KEYTYPE_RSA, )); // 获取相应的公钥 $publicKey = openssl_pkey_get_details($privateKey); $publicKey = $publicKey["key"...
}// 提取私钥openssl_pkey_export($res,$privateKey,NULL,$config);// <-- CONFIG ARRAY// 生成公钥$publicKey=openssl_pkey_get_details($res);$publicKey=$publicKey["key"];echo"私钥:<br/>".$privateKey."<br/>";echo"公钥:<br/>".$publicKey."<br/>";// 释放资源openssl_free_key($res)...
生成公钥的方法是使用`openssl_pkey_get_details`函数来获取私钥的详情,包括公钥部分。 “`php $privateKeyDetails = openssl_pkey_get_details($privateKey); $publicKey = $privateKeyDetails[‘key’]; “` 获取到的公钥`$publicKey`也是PEM格式的字符串,可以保存到文件中或者传递给其他人。
在PHP中同样可以使用openssl扩展来进行非对称密钥的解析。具体步骤如下:1) 使用openssl_pkey_get_private或openssl_pkey_get_public函数打开密钥文件或将密钥内容保存在变量中;2) 使用openssl_pkey_get_details函数获取密钥的详细信息,包括密钥长度和类型等。 3. 其他方法:除了使用openssl扩展,还可以使用其他方法来解析...
Steps to reproduce: Run vendor/bin/bunq-install (Windows 10, PHP 7.2) What should happen: I guess it should be working. What happens: It throws an error. Traceback PHP Warning: openssl_pkey_get_details() expects parameter 1 to be resourc...
<?php // 生成私钥 $privateKey = openssl_pkey_new(array( "private_key_bits" => 2048, // 密钥长度 "private_key_type" => OPENSSL_KEYTYPE_RSA, // 密钥类型 )); if (!$privateKey) { die("无法生成私钥"); } // 生成公钥 $publicKey = openssl_pkey_get_details($privateKey); $public...
$res = openssl_pkey_new($config); if ( $res == false ) return false; openssl_pkey_export($res, $private_key); $public_key = openssl_pkey_get_details($res); $public_key = $public_key["key"]; file_put_contents("./cert_public.key", $public_key); ...