这是我的第一次加密尝试。这是我的代码:
$privateKey = openssl_pkey_new(array(
'private_key_bits' => 2048, //size of key
'private_key_type' => OPENSSL_KEYTYPE_RSA,
));
//save the private key to private.key file. Never share this file with anyone.
openssl_pkey_export_to_file( $privateKey, 'private.key' );
//generate the public key for the private key
$a_key = openssl_pkey_get_details( $privateKey );
//save the public key in public.key file. Send this file to anyone who wants to send you the encrypted data.
file_put_contents( 'public.key', $a_key['key'] );
//free the private key
openssl_free_key( $privateKey );
我收到以下错误;
警告:openssl_pkey_export_to_file():无法从第40行的C:\ xampp \ htdocs \ PHP \ 25000.php中的参数1获取密钥
警告:openssl_pkey_get_details()期望参数1为资源,第43行的C:\ xampp \ htdocs \ PHP \ 25000.php中给出布尔值
警告:openssl_free_key()要求参数1为资源,布尔值在第48行的C:\ xampp \ htdocs \ PHP \ 25000.php中给出
我已经搜索过了。我发现我必须做以下事情:
我不确定我是否做过这些,我想知道这是否是我错误的原因?