我目前正在将我的项目从Laravel 4迁移到Laravel 5,我仍然是Laravel和OOP的新手用户,但是到目前为止一切都很顺利。
但是,在我的L4项目中,我使用phpseclib生成SSH密钥,我以以下方式导入了这些密钥:
MyController.php
...
include('../app/libs/phpseclib0.3.10/Crypt/RSA.php');
$rsa = new Crypt_RSA();
...似乎不再起作用了:
syntax error, unexpected 'if' (T_IF), expecting identifier (T_STRING) ./app/libs/phpseclib0.3.10/Crypt/RSA.php
/**
* Include Crypt_Random
*/
// the class_exists() will only be called if the crypt_random_string function hasn't been defined and
// will trigger a call to __autoload() if you're wanting to auto-load classes
// call function_exists() a second time to stop the include_once from being called outside
// of the auto loader
if (!function_exists('crypt_random_string')) {
include_once 'Random.php';
}我知道有一个phpseclib包:https://packagist.org/packages/phpseclib/phpseclib
我还知道如何在我的L5项目中安装它。
但是,我不知道如何在我的Laravel 5项目中使用phpseclib包。
因此,在我的L5项目中安装了phpseclib包之后,如何创建类似于以下内容的SSH键:
$rsa = new Crypt_RSA();发布于 2015-02-26 11:11:58
PHPSec确实使用了composer,您应该能够只使用composer require "phpseclib/phpseclib=~0.3.10"并使其可用(自动加载)。
$rsa = new \Crypt_RSA();发布于 2015-08-15 19:53:49
重新处理this other answer并查看供应商/phpseclib/文件夹,我设法让它使用以下语法:
use phpseclib\Crypt\RSA;
...
...
$rsa = new RSA();
$rsa->setPublicKeyFormat(RSA::PUBLIC_FORMAT_OPENSSH);
extract($rsa->createKey());
echo "$publickey\r\n\r\n$privatekey";至少,它在phpseclib版本^2.0上工作。
https://stackoverflow.com/questions/28739971
复制相似问题