【问题标题】:No RSA private key generated没有生成 RSA 私钥
【发布时间】:2019-07-18 17:24:52
【问题描述】:

我是 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);
}

【问题讨论】:

    标签: php openssl rsa


    【解决方案1】:

    尝试在 Xampp 文件夹下查找,例如 C:\xampp

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-11
      • 1970-01-01
      • 2019-08-15
      • 2023-03-29
      • 1970-01-01
      • 2018-10-07
      • 1970-01-01
      相关资源
      最近更新 更多