簡體   English   中英

沒有生成RSA私鑰

[英]No RSA private key generated

我是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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM