当前位置: 首页>>代码示例>>PHP>>正文


PHP RSA::setPrivateKey方法代码示例

本文整理汇总了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());
    }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:16,代码来源:LoadKeyTest.php

示例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]));
                 }
             }
         }
     }
 }
开发者ID:hguenot,项目名称:yii2-gsftp,代码行数:27,代码来源:SftpDriver.php


注:本文中的phpseclib\Crypt\RSA::setPrivateKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。