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


PHP Crypt_RSA::setPassword方法代码示例

本文整理汇总了PHP中Crypt_RSA::setPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP Crypt_RSA::setPassword方法的具体用法?PHP Crypt_RSA::setPassword怎么用?PHP Crypt_RSA::setPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Crypt_RSA的用法示例。


在下文中一共展示了Crypt_RSA::setPassword方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * @param string $pem_format
  * @param string $password
  * @throws RSABadPEMFormat
  */
 public function __construct($pem_format, $password = null)
 {
     $this->pem_format = $pem_format;
     $this->rsa_imp = new \Crypt_RSA();
     if (!empty($password)) {
         $this->rsa_imp->setPassword($password);
     }
     $res = $this->rsa_imp->loadKey($this->pem_format, CRYPT_RSA_PRIVATE_FORMAT_PKCS1);
     if (!$res) {
         throw new RSABadPEMFormat(sprintf('pem %s', $pem_format));
     }
     $this->n = $this->rsa_imp->modulus;
 }
开发者ID:smarcet,项目名称:jose4php,代码行数:18,代码来源:_AbstractRSAKeyPEMFornat.php

示例2: app_login

 /**
  * app_login
  *
  * @param   string  $server
  *
  * @return	bool
  **/
 public function app_login($server)
 {
     $ftp_id = $this->mod_config['FTP_UserName'];
     $ftp_pass = $this->mod_config['FTP_password'];
     // LOGIN
     //		@define('NET_SFTP_LOGGING', NET_SFTP_LOG_COMPLEX);
     @define('NET_SFTP_LOGGING', NET_SFTP_LOG_SIMPLE);
     $this->Verbose = TRUE;
     //TRUE or FALSE
     $this->LocalEcho = FALSE;
     //$this->Passive(TRUE);
     $key = new Crypt_RSA();
     $key->setPassword($ftp_pass);
     $key->loadKey($this->mod_config['SSH_key']);
     $port = (int) $this->mod_config['SSH_port'];
     //phpseclib
     $this->sftp = new Net_SFTP($server, $port);
     if (!$this->sftp->login($ftp_id, $key)) {
         $this->mes .= "SSH Login Failed<br />\n";
         $this->mes .= $this->getSSH2Errors();
         return false;
     }
     $this->mes .= "PWD:" . $this->sftp->pwd() . "<br />\n";
     $this->mes .= $this->getSSH2Log();
     return true;
 }
开发者ID:nao-pon,项目名称:xupdate,代码行数:33,代码来源:Ssh2.class.php

示例3: connect

 public function connect($test = false)
 {
     if (!$this->connection or $test) {
         $server = $this->server;
         require_once 'Crypt/RSA.php';
         require_once 'Net/SFTP.php';
         $this->connection = new \Net_SFTP($server['host'], $server['port'], 10);
         $logged_in = false;
         if (isset($server['sftp_key'])) {
             $key = new \Crypt_RSA();
             if (isset($server['pass']) && !empty($server['pass'])) {
                 $key->setPassword($server['pass']);
             }
             $key->loadKey(file_get_contents($server['sftp_key']));
             $logged_in = $this->connection->login($server['user'], $key);
             if (!$logged_in) {
                 Helpers::error("Could not login to {$this->host}. It may be because the key requires a passphrase, which you need to specify it as the 'pass' attribute.");
             }
         } else {
             $logged_in = $this->connection->login($server['user'], $server['pass']);
             if (!$logged_in) {
                 Helpers::error("Could not login to {$this->host}");
             }
         }
         if (!$this->connection->chdir($server['path'])) {
             Helpers::error("Could not change the directory to {$server['path']} on {$this->host}");
         }
         Helpers::logmessage("Connected to: {$this->host}");
         $this->current_commit = $this->get_file('REVISION', true);
     }
     if ($test) {
         $this->disconnect();
     }
 }
开发者ID:rudraks,项目名称:application,代码行数:34,代码来源:Sftp.php

示例4: connect

 function connect()
 {
     $this->link = new Net_SFTP($this->options['hostname'], $this->options['port']);
     if (!$this->link) {
         $this->errors->add('connect', sprintf(__('Failed to connect to SSH2 Server %1$s:%2$s'), $this->options['hostname'], $this->options['port']));
         return false;
     }
     if (!$this->keys) {
         if (!$this->link->login($this->options['username'], $this->options['password'])) {
             $this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username']));
             return false;
         }
     } else {
         $rsa = new Crypt_RSA();
         if ($this->password) {
             $rsa->setPassword($this->options['password']);
         }
         $rsa->loadKey($this->options['private_key']);
         if (!$this->link->login($this->options['username'], $rsa)) {
             $this->errors->add('auth', sprintf(__('Private key incorrect for %s'), $this->options['username']));
             return false;
         }
     }
     return true;
 }
开发者ID:tlandn,项目名称:akvo-web,代码行数:25,代码来源:class-wp-filesystem-ssh2.php

示例5: connect

 function connect()
 {
     $this->link = new Net_SFTP($this->options['hostname'], $this->options['port']);
     if (!$this->keys) {
         if (!$this->link->login($this->options['username'], $this->options['password'])) {
             if ($this->handle_connect_error()) {
                 return false;
             }
             $this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username']));
             return false;
         }
     } else {
         $rsa = new Crypt_RSA();
         if ($this->password) {
             $rsa->setPassword($this->options['password']);
         }
         $rsa->loadKey($this->options['private_key']);
         if (!$this->link->login($this->options['username'], $rsa)) {
             if ($this->handle_connect_error()) {
                 return false;
             }
             $this->errors->add('auth', sprintf(__('Private key incorrect for %s'), $this->options['username']));
             $this->errors->add('auth', __('Make sure that the key you are using is an RSA key and not a DSA key'));
             return false;
         }
     }
     return true;
 }
开发者ID:DanielWildeboer,项目名称:PVNG,代码行数:28,代码来源:class-wp-filesystem-ssh2.php

示例6: deploy

 public function deploy()
 {
     $releaseId = $this->dataBase->startRelease();
     $ssh = new Net_SSH2(SSH_SERVER);
     $key = new Crypt_RSA();
     $key->setPassword(SSH_PASSWORD);
     $key->loadKey(file_get_contents(PATH_TO_PRIVATE_KEY));
     if (!$ssh->login(SSH_LOGIN, $key)) {
         $this->dataBase->logStep($releaseId, 'ssh ' . SSH_SERVER, ['error' => 'Login failed'], 1);
         exit('Login Failed');
     }
     $ssh->enableQuietMode();
     $command = $this->bash->dtLock('sandbox-mercury', 'mercury');
     $output['success'] = $ssh->exec($command);
     $output['error'] = $ssh->getStdError();
     $this->dataBase->logStep($releaseId, $command, $output, $ssh->getExitStatus());
     $command = $this->bash->dtPrep('sandbox-mercury', 'mercury', ["mercury" => "dev"]);
     $output['success'] = $ssh->exec($command);
     $output['error'] = $ssh->getStdError();
     $this->dataBase->logStep($releaseId, $command, $output, $ssh->getExitStatus());
     $command = $this->bash->dtPush('sandbox-mercury', 'mercury');
     $output['success'] = $ssh->exec($command);
     $output['error'] = $ssh->getStdError();
     $this->dataBase->logStep($releaseId, $command, $output, $ssh->getExitStatus());
 }
开发者ID:Warkot,项目名称:Bolt,代码行数:25,代码来源:Release.class.php

示例7: getAuthentication

 /**
  * @return RsaKey the rsa key
  */
 public function getAuthentication()
 {
     $key = new RsaKey();
     $key->loadKey(file_get_contents($this->key));
     if (!is_null($this->password)) {
         $key->setPassword($this->password);
     }
     return $key;
 }
开发者ID:sayiho,项目名称:Jumper,代码行数:12,代码来源:Rsa.php

示例8: connectWithKey

 function connectWithKey($hostName, $userName, $keyFileName, $port = 22, $keyFilePassword = '')
 {
     $key = new Crypt_RSA();
     if ($keyFilePassword) {
         $key->setPassword($keyFilePassword);
     }
     $key->loadKey(file_get_contents($keyFileName));
     $this->connect($hostName, $userName, $key, $port);
 }
开发者ID:jagermesh,项目名称:bright,代码行数:9,代码来源:BrSFTP.php

示例9: getPrivateKey

 /**
  * Returns the private key to be used for authentication to the remote server.
  *
  * @return \Crypt_RSA instance or null in case of a failure to load the key.
  */
 private function getPrivateKey()
 {
     $key = new \Crypt_RSA();
     $key->setPassword(\OC::$server->getConfig()->getSystemValue('secret', ''));
     if (!$key->loadKey($this->privateKey)) {
         // Should this exception rather than return null?
         return null;
     }
     return $key;
 }
开发者ID:samj1912,项目名称:repo,代码行数:15,代码来源:sftp_key.php

示例10: generateSshKeys

 private function generateSshKeys()
 {
     $rsa = new \Crypt_RSA();
     $rsa->setPublicKeyFormat(CRYPT_RSA_PUBLIC_FORMAT_OPENSSH);
     $rsa->setPassword(\OC::$server->getConfig()->getSystemValue('secret', ''));
     $key = $rsa->createKey();
     // Replace the placeholder label with a more meaningful one
     $key['publicKey'] = str_replace('phpseclib-generated-key', gethostname(), $key['publickey']);
     return $key;
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:10,代码来源:ajaxcontroller.php

示例11:

 function ssh2_auth_pubkey_file($session, $username, $pubkeyfile, $privkeyfile, $passphrase = NULL)
 {
     $privkey = new Crypt_RSA();
     if (isset($passphrase)) {
         $privkey->setPassword($passphrase);
     }
     $privkey->loadKey(file_get_contents($privkeyfile));
     if ($privkey === false) {
         return false;
     }
     return $session->login($username, $privkey);
 }
开发者ID:jamesduan,项目名称:etbackuptool,代码行数:12,代码来源:phpseclib.php

示例12: generateKey

 /**
  * Generates random key with optonal passphrase and stores it
  * in the model
  */
 function generateKey($pack = null)
 {
     $rsa = new Crypt_RSA();
     if ($pack) {
         $rsa->setPassword($pack);
     }
     $rsa->setPublicKeyFormat(CRYPT_RSA_PUBLIC_FORMAT_OPENSSH);
     $key = $rsa->createKey();
     $this['kind'] = 'key';
     $this['host'] = '*';
     $this['data'] = $key['privatekey'];
     $this['is_secure'] = (bool) $pack;
     $this['notes'] = $key['publickey'];
 }
开发者ID:kmattimo,项目名称:dokku-alt-manager,代码行数:18,代码来源:Keychain.php

示例13: connect

 public function connect()
 {
     // we have to mangle the include path a little to find our plugins
     $oldIncludePath = get_include_path();
     set_include_path($oldIncludePath . ':' . TL_ROOT . '/plugins/phpseclib/:' . TL_ROOT . '/plugins/phpseclib/Net:' . TL_ROOT . '/plugins/phpseclib/Crypt');
     include 'SFTP.php';
     if ($GLOBALS['TL_CONFIG']['sftpKeyFile']) {
         include 'RSA.php';
     }
     set_include_path($oldIncludePath);
     $this->ftpHost = $GLOBALS['TL_CONFIG']['ftpHost'];
     $this->ftpPort = $GLOBALS['TL_CONFIG']['ftpPort'];
     $this->ftpUser = $GLOBALS['TL_CONFIG']['ftpUser'];
     if ($GLOBALS['TL_CONFIG']['sftpKeyFile']) {
         $key = new Crypt_RSA();
         if ($GLOBALS['TL_CONFIG']['sftpKeyPass']) {
             $key->setPassword($GLOBALS['TL_CONFIG']['sftpKeyPass']);
         }
         $key->loadKey(file_get_contents($GLOBALS['TL_CONFIG']['sftpKeyFile']));
         $this->ftpPass = $key;
     } else {
         $this->ftpPass = $GLOBALS['TL_CONFIG']['ftpPass'];
     }
     $this->ftpPath = $GLOBALS['TL_CONFIG']['ftpPath'];
     // Connect to FTP server
     if (!is_numeric($this->ftpPort) || $this->ftpPort == 0) {
         $this->ftpPort = 22;
     }
     if ($GLOBALS['TL_CONFIG']['debugSmhExtended']) {
         define('NET_SSH2_LOGGING', true);
         define('NET_SFTP_LOGGING', true);
     }
     if (($resConnection = new Net_SFTP($this->ftpHost, $this->ftpPort, 5)) != false) {
         // Login
         if (!$resConnection->login($this->ftpUser, $this->ftpPass)) {
             throw new Exception('Could not login to sftp: ' . $resConnection->getLastError() . (defined('NET_SSH2_LOGGING') ? implode("\n", $resConnection->message_number_log) : ''));
         }
         // security, clean user id and password as we won't need them anymore.
         $this->ftpUser = NULL;
         $this->ftpPass = NULL;
         // change to root directory to ensure we can really work.
         $resConnection->chdir($this->ftpPath);
         $this->resConnection = $resConnection;
         return $resConnection;
     } else {
         throw new Exception('Could not connect to sftp: ' . $resConnection->getLastError());
     }
 }
开发者ID:unmaintained-stuff,项目名称:tl_smhextended,代码行数:48,代码来源:SMHSFTP.php

示例14: InitSSH

 private final function InitSSH()
 {
     if ($this->ssh == null) {
         if (!$this->IsIPAddress($_SESSION['host'])) {
             //return print_r($_SESSION, 1);
             return 'InitSSH: Must select a Server to manage';
         }
         $this->ssh = new Net_SFTP($_SESSION['host']);
         $user = $pass = $privkey = $privpass = '';
         list($user, $pass, $privpass) = explode(' ', $this->Decrypt($_SESSION['cred']));
         //return "user:$user, pass:$pass";
         if (!$_SESSION['priv']) {
             if (!$this->ssh->login($user, $pass)) {
                 return 'InitSSH: Keyboard-Interactive Login Failed';
             }
         } else {
             $privkey = $this->Decrypt($_SESSION['priv']);
             if ($this->GetPrivateHostKeyType($privkey) != 'RSA') {
                 return 'InitSSH: Private Host Key Login Failed, Key not RSA';
             } else {
                 $key = new Crypt_RSA();
                 if ($privpass) {
                     $key->setPassword($privpass);
                 }
                 $key->loadKey($privkey);
                 if (!$this->ssh->login($user, $key)) {
                     return 'InitSSH: Private Host Key Login Failed';
                 }
             }
         }
     } else {
         $pubkey = $this->ssh->getServerPublicHostKey();
         if ($_SESSION['pubhost'] and $pubkey !== $this->Decrypt($_SESSION['pubhost'])) {
             return 'InitSSH: Possible Man-in-the-Middle Attack!';
         } else {
             if (!$_SESSION['pubhost']) {
                 $_SESSION['pubhost'] = $this->Encrypt($pubkey);
             }
         }
     }
     // http://phpseclib.sourceforge.net/ssh/examples.html#interactive
     //$_SESSION['uprompt'] = $_SESSION['rprompt'] = '';
     $this->GetSSHPrompts($pass, false);
     return true;
 }
开发者ID:nulled,项目名称:anypanel,代码行数:45,代码来源:PanelCommon.core.class.php

示例15: ssh_connect

function ssh_connect($host)
{
    dbg_log("Connecting over SSH to {$host}");
    #define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);
    $ssh = new Net_SSH2($host);
    $key = new Crypt_RSA();
    $key->setPassword(get_config()->host_ssh_private_key_password);
    $keyPath = get_config()->host_ssh_private_key;
    $keyString = file_get_contents($keyPath);
    $userString = get_config()->host_ssh_username;
    if (!$key->loadKey($keyString)) {
        dbg_log(var_dump($ssh->getErrors(), true));
        exit("cannot import key {$keyPath}");
    }
    if (!$ssh->login($userString, $key)) {
        dbg_log($ssh->getLastError());
        exit('Login Failed');
    }
    return $ssh;
}
开发者ID:alexandrubordei,项目名称:basic_marathon_orchestration,代码行数:20,代码来源:ssh.php


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