当前位置: 首页>>代码示例>>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;未经允许,请勿转载。