PhpStorm致命错误:未找到类'Crypt_RSA'(phpseclib)

时间:2018-05-10 08:10:32

标签: php phpstorm phpseclib

我正在尝试在PhpStorm中添加phpseclib作为外部库。

我从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公共加密。

1 个答案:

答案 0 :(得分:0)

  

无法打开' 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设置为/