本文整理汇总了PHP中phpseclib\Crypt\RSA::setPrivateKey方法的典型用法代码示例。如果您正苦于以下问题:PHP RSA::setPrivateKey方法的具体用法?PHP RSA::setPrivateKey怎么用?PHP RSA::setPrivateKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpseclib\Crypt\RSA
的用法示例。
在下文中一共展示了RSA::setPrivateKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetPrivate
public function testSetPrivate()
{
$rsa = new RSA();
$key = '-----BEGIN RSA PUBLIC KEY-----
MIIBCgKCAQEA61BjmfXGEvWmegnBGSuS+rU9soUg2FnODva32D1AqhwdziwHINFa
D1MVlcrYG6XRKfkcxnaXGfFDWHLEvNBSEVCgJjtHAGZIm5GL/KA86KDp/CwDFMSw
luowcXwDwoyinmeOY9eKyh6aY72xJh7noLBBq1N0bWi1e2i+83txOCg4yV2oVXhB
o8pYEJ8LT3el6Smxol3C1oFMVdwPgc0vTl25XucMcG/ALE/KNY6pqC2AQ6R2ERlV
gPiUWOPatVkt7+Bs3h5Ramxh7XjBOXeulmCpGSynXNcpZ/06+vofGi/2MlpQZNhH
Ao8eayMp6FcvNucIpUndo1X8dKMv3Y26ZQIDAQAB
-----END RSA PUBLIC KEY-----';
$this->assertTrue($rsa->loadKey($key));
$this->assertTrue($rsa->setPrivateKey());
$this->assertGreaterThanOrEqual(1, strlen("{$rsa}"));
$this->assertFalse($rsa->getPublicKey());
}
示例2: login
public function login()
{
$this->connectIfNeeded(false);
if ($this->user === null) {
throw new FtpException(Yii::t('gsftp', 'Could not login to SFTP server "{host}" on port "{port}" without username.', ['host' => $this->host, 'port' => $this->port]));
} else {
if ($this->privateKeyFile != null) {
$key = new RSA();
if ($this->pass != null && !empty($this->pass)) {
$key->setPassword($this->pass);
}
if ($this->publicKeyFile != null && !empty($this->publicKeyFile)) {
$key->setPublicKey(self::_readKeyFile('Public', $this->publicKeyFile));
}
$key->setPrivateKey(self::_readKeyFile('Private', $this->privateKeyFile));
if (!$this->handle->login($this->user, $key)) {
throw new FtpException(Yii::t('gsftp', 'Could not login to SFTP server "{host}" on port "{port}" with user "{user}" using RSA key.', ['host' => $this->host, 'port' => $this->port, 'user' => $this->user]));
}
} else {
if ($this->pass != null && !empty($this->pass)) {
if (!$this->handle->login($this->user, $this->pass)) {
throw new FtpException(Yii::t('gsftp', 'Could not login to SFTP server "{host}" on port "{port}" with user "{user}".', ['host' => $this->host, 'port' => $this->port, 'user' => $this->user]));
}
}
}
}
}