我需要在我的php项目中使用openssl,所以我使用openssl创建了一个测试php页面.但是,我不断收到这些错误,我不知道为什么.openssl已启用.
警告:openssl_pkey_export()[function.openssl-pkey-export]:无法从第18行的C:\ wamp\www\opensslsample\index.php中的参数1获取密钥
警告:openssl_pkey_get_details()期望参数1为资源,布线在第21行的C:\ wamp\www\opensslsample\index.php中给出
<?php
 //echo phpinfo();
   $privateKey = openssl_pkey_new(array(
'private_key_bits' => 1024,
'private_key_type' => OPENSSL_KEYTYPE_RSA,
));
openssl_pkey_export($privateKey, $privkey,"123");
$pubkey=openssl_pkey_get_details($privateKey);
$pubkey=$pubkey["key"];
?>
小智 12
如果您在Windows上,这可能会有所帮助:
OPENSSL应该正常工作.
查看openssl_error_string。我的猜测是你的 openssl.cnf 文件丢失了或者什么的。
或者,您可以使用phpseclib(一个纯 PHP RSA 实现)来生成密钥。例如。
<?php
include('Crypt/RSA.php');
$rsa = new Crypt_RSA();
extract($rsa->createKey());
echo "$privatekey<br />$publickey";
?>
| 归档时间: | 
 | 
| 查看次数: | 9872 次 | 
| 最近记录: |