當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。