if (isset($_SERVER['HTTPS']) )
{
echo "SECURE: This page is being accessed through a secure connection.";
}
else
{
echo "UNSECURE: This page is being access through an unsecure connection.";
}
$config = array(
"digest_alg" => "sha512",
"private_key_bits" => 385,
"private_key_type" => OPENSSL_KEYTYPE_RSA,
);
// Create the keypair
$res=openssl_pkey_new($config);
// Get private key
openssl_pkey_export($res, $privatekey);
// Get public key
$publickey=openssl_pkey_get_details($res);
$publickey= $publickey["key"];
echo "Private Key:
$privatekey
Public Key:
$publickey
";
$cleartext = '1234 567gongji 珍珠港虎虎虎';
echo "Clear text:
$cleartext
";
openssl_public_encrypt($cleartext, $crypttext, $publickey);
echo "Crypt text:$crypttext
";
openssl_private_decrypt($crypttext, $decrypted, $privatekey);
echo "Decrypted text:
$decrypted
";
?>
["key"] 这个能理解成 php 保留的数组值吗?