當前位置: 首頁>>代碼示例>>PHP>>正文


PHP RSA::setComment方法代碼示例

本文整理匯總了PHP中phpseclib\Crypt\RSA::setComment方法的典型用法代碼示例。如果您正苦於以下問題:PHP RSA::setComment方法的具體用法?PHP RSA::setComment怎麽用?PHP RSA::setComment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在phpseclib\Crypt\RSA的用法示例。


在下文中一共展示了RSA::setComment方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: generateKeyPair

 public static function generateKeyPair($comment = 'dogpro')
 {
     $rsa = new RSA();
     $rsa->setPublicKeyFormat(RSA::PUBLIC_FORMAT_OPENSSH);
     $rsa->setComment($comment);
     return $rsa->createKey();
 }
開發者ID:dzirg44,項目名稱:dogpro,代碼行數:7,代碼來源:SSH.php

示例2: createRSA

 protected function createRSA()
 {
     $rsa = new RSA();
     $rsa->setPublicKeyFormat(RSA::PUBLIC_FORMAT_OPENSSH);
     $rsa->setComment($this->config['routerboard']['backupuser'] . "@backup");
     $key = $rsa->createKey(2048);
     if (!empty($key)) {
         // be safe
         $this->backupExistRSA();
         // create id_rsa.pub (public key)
         $this->fsys->dumpFile($this->config['system']['ssh-dir'] . DIRECTORY_SEPARATOR . 'id_rsa.pub', $key['publickey']);
         // create id_rsa (private key)
         $this->fsys->dumpFile($this->config['system']['ssh-dir'] . DIRECTORY_SEPARATOR . 'id_rsa', $key['privatekey']);
         // set permissions -rw-------
         $this->fsys->chmod($this->config['system']['ssh-dir'] . DIRECTORY_SEPARATOR . 'id_rsa', 0600);
         $this->fsys->chmod($this->config['system']['ssh-dir'] . DIRECTORY_SEPARATOR . 'id_rsa.pub', 0600);
         // backup existing RSA files for sure.
         $this->backupExistRSA('routerboard-backup');
         $this->logger->log("The SSH-RSA public key has been created. Never delete those files! (id_rsa,id_rsa.pub)", $this->logger->setNotice());
         return;
     }
     throw new Exception(get_class($this) . " can not create the ssh-rsa public key file!");
 }
開發者ID:heximcz,項目名稱:routerboard-backup,代碼行數:23,代碼來源:SecureTools.php

示例3: getPair

 public function getPair()
 {
     $installationUuid = $this->name;
     $publicKeyName = $this->getPublicKeyPath();
     $privateKeyName = $this->getPrivateKeyPath();
     if (Storage::exists($publicKeyName) === false || Storage::exists($privateKeyName) === false) {
         $rsa = new RSA();
         $rsa->setPublicKeyFormat(RSA::PUBLIC_FORMAT_OPENSSH);
         $rsa->setComment('fodor@fodor.xyz');
         $keys = $rsa->createKey(2048);
         $privateKey = $keys['privatekey'];
         $publicKey = $keys['publickey'];
         Storage::disk('local')->put($privateKeyName, $privateKey);
         Storage::disk('local')->put($publicKeyName, $publicKey);
     }
     return ['public' => $publicKeyName, 'private' => $privateKeyName];
     /*$sshConnection = ssh2_connect('mycloud.smellynose.com', 22, array('hostkey'=>'ssh-rsa'));
       $sshSuccess = ssh2_auth_pubkey_file(
           $sshConnection,
           'ahindle',
           storage_path('app/' . $publicKeyName),
           storage_path('app/' . $privateKeyName)
       );*/
 }
開發者ID:fodorxyz,項目名稱:fodor,代碼行數:24,代碼來源:Keys.php


注:本文中的phpseclib\Crypt\RSA::setComment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。