我正在尝试将phpseclib添加为PhpStorm中的外部库。
我已经从GitHub下载了phpseclib,提取了文件并在此处添加了phpseclib:Settings | Languages & Frameworks | PHP | Include Path
。
之后$phpsec = new Crypt_RSA();
并运行,但给了我这个错误:
致命错误:找不到类"Crypt_RSA">
之后,我尝试了以下行:
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
include('Net/SSH2.php');
include("Crypt/RSA.php");
给我这些错误:
Warning: include(Net/SSH2.php): failed to open stream: No such file or directory
Warning: include(): Failed opening 'Net/SSH2.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear:phpseclib')
Warning: include(Crypt/RSA.php): failed to open stream: No such file or directory
Warning: include(): Failed opening 'Crypt/RSA.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear:phpseclib')
Fatal error: Class 'Crypt_RSA' not found
还尝试了这个:
include('library/php/Crypt/RSA.php');
给出了相同的错误。
添加 phpseclib 库并使用它的真正方法是什么。
我的主要目的是使用 sha256 进行 RSA OAEP 公共加密。
打开"Crypt/RSA.php"进行包含失败(include_path='.:/usr/share/php:/usr/share/pear:phpseclib'(
看来你的PATH_SEPARATOR
是:
而不是/
.改变:
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
至
set_include_path(get_include_path() .'/phpseclib');
或将"您的PATH_SEPARATOR
"设置为/
。