php - PhpStorm 致命错误:找不到类“Crypt_RSA”(phpseclib)
问题描述
我正在尝试将 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')
似乎YoursPATH_SEPARATOR
不是:
. /
改变:
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
至
set_include_path(get_include_path() .'/phpseclib');
或将 Your 设置PATH_SEPARATOR
为/
.
推荐阅读
- java - Android Studio 我无法在课堂上获得回报。(火库)
- r - 通过预定义的协方差矩阵计算逐行马氏距离
- python - 如何保留自动添加的 argparse 帮助参数,但从中删除 -h 以便我可以将该选项用于另一个参数
- python - 将数据框保存为python中的另一个值
- apache-kafka - 从 Postgres 表到具有更新跟踪的 KSQL 表
- pine-script - 首支蜡烛收盘价
- nginx - 当 2 个域指向同一服务器时,HTTPS Nginx 重定向过多
- qt - QT QML 没有动态调整大小
- r - 如何在 R 的另一个数据框中获取我正在寻找的值的行和列
- cassandra - 三节点 Cassandra 集群所有节点在同一个 dc 中配置不同的机架