php - 没有生成 RSA 私钥
问题描述
我是 PHP 新手,我按照本教程进行操作,https://www.virendrachandak.com/techtalk/encryption-using-php-openssl/
使用下面的代码,我的根文件夹中没有生成 private.key 文件。有什么不对?我在 Windows 10 上运行 XAMPP,并且我已将环境变量设置为指向我的 XAMPP 的 openssl.cnf 文件。
function generate_public_private_keys() {
$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 the person developing the ticket scanner app
file_put_contents('public.key', $a_key['key']);
// Free the private Key.
openssl_free_key($privateKey);
}
解决方案
尝试在您的 Xampp 文件夹下查看,例如 C:\xampp
推荐阅读
- java - 将用户插入用于 getter 时出现问题
- swift - 调用 URLSession 后我不能做其他工作
- azure - 他们是执行自定义 python 或任何语言的任何选项。作为 ARM 模板执行 immd 的一部分,新创建的 VM 上的脚本。虚拟机创建后?
- c++ - 流操纵器的自由函数与直接重载运算符<<
- pine-script - 短信号和长信号的数量
- amazon-web-services - 我想用 html 向用户展示来自 S3 的视频
- python - 我需要帮助我该如何摆脱这个?
- python - 如何在pygame中重复我的功能
- 2d-games - Godot 跳转动画在输入稍有延迟后开始
- r - 将标签与ggplot中的日历季度对齐