⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 001.phpt

📁 PHP v6.0 For Linux 运行环境:Win9X/ WinME/ WinNT/ Win2K/ WinXP
💻 PHPT
字号:
--TEST--OpenSSL private key functions--SKIPIF--<?php if (!extension_loaded("openssl")) die("skip"); if (!@openssl_pkey_new()) die("skip cannot create private key"); ?>--FILE--<?phpecho "Creating private key\n";/* stack up some entropy; performance is not critical, * and being slow will most likely even help the test. */for ($z = "", $i = 0; $i < 1024; $i++) {	$z .= $i * $i;	if (function_exists("usleep"))		usleep($i);}$privkey = openssl_pkey_new();if ($privkey === false)	die("failed to create private key");$passphrase = "banana";$key_file_name = tempnam("/tmp", "ssl");if ($key_file_name === false)	die("failed to get a temporary filename!");echo "Export key to file\n";openssl_pkey_export_to_file($privkey, $key_file_name, $passphrase) or die("failed to export to file $key_file_name");echo "Load key from file - array syntax\n";$loaded_key = openssl_pkey_get_private(array("file://$key_file_name", $passphrase));if ($loaded_key === false)	die("failed to load key using array syntax");openssl_pkey_free($loaded_key);echo "Load key using direct syntax\n";$loaded_key = openssl_pkey_get_private("file://$key_file_name", $passphrase);if ($loaded_key === false)	die("failed to load key using direct syntax");openssl_pkey_free($loaded_key);echo "Load key manually and use string syntax\n";$key_content = file_get_contents($key_file_name);$loaded_key = openssl_pkey_get_private($key_content, $passphrase);if ($loaded_key === false)	die("failed to load key using string syntax");openssl_pkey_free($loaded_key);echo "OK!\n";@unlink($key_file_name);?>--EXPECT--Creating private keyExport key to fileLoad key from file - array syntaxLoad key using direct syntaxLoad key manually and use string syntaxOK!

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -