2010-11-27 72 views

回答

8

要生成密鑰對:

<?php 
/* Create the private and public key */ 
$res = openssl_pkey_new(); 

/* Extract the private key from $res to $privKey */ 
openssl_pkey_export($res, $privKey); 

/* Extract the public key from $res to $pubKey */ 
$pubKey = openssl_pkey_get_details($res); 
$pubKey = $pubKey["key"]; 
?> 

要保存的關鍵目標文件:

file_put_contents($file, $key); 
相關問題