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


PHP Crypt_RSA::createKey方法代码示例

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


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

示例1: buildKeyPair

 /**
  * @param $bits
  * @return KeyPair
  */
 public function buildKeyPair($bits)
 {
     $this->rsa_imp->setPrivateKeyFormat(CRYPT_RSA_PRIVATE_FORMAT_PKCS1);
     $this->rsa_imp->setPublicKeyFormat(CRYPT_RSA_PUBLIC_FORMAT_PKCS1);
     $list = $this->rsa_imp->createKey($bits);
     return new KeyPair(new _RSAPublicKeyPEMFornat($list['publickey']), new _RSAPrivateKeyPEMFornat($list['privatekey']));
 }
开发者ID:smarcet,项目名称:jose4php,代码行数:11,代码来源:RSAFacade.php

示例2: signNewCert

function signNewCert()
{
    if (!$GLOBALS['isCA']) {
        return false;
    } else {
        $CAPrivKey = new Crypt_RSA();
        $CAPrivKey->loadKey($GLOBALS['CAPrivKeyStr']);
        $CAx509 = new File_X509();
        $CAx509->loadX509($GLOBALS['CAPubX509']);
        //认证证书
        $privKey = new Crypt_RSA();
        $keyArray = $CAPrivKey->createKey($GLOBALS['RSALength']);
        $privKey->loadKey($keyArray['privatekey']);
        $pubKey = new Crypt_RSA();
        $pubKey->loadKey($keyArray['publickey']);
        $pubKey->setPublicKey();
        $subject = new File_X509();
        $subject->setDNProp('id-at-organizationName', $GLOBALS['CAname'] . ' cert');
        $subject->setPublicKey($pubKey);
        $issuer = new File_X509();
        $issuer->setPrivateKey($CAPrivKey);
        $issuer->setDN($CAx509->getDN());
        $x509 = new File_X509();
        $result = $x509->sign($issuer, $subject);
        return array('privateKey' => $privKey->getPrivateKey(), 'publicX509' => $x509->saveX509($result));
    }
}
开发者ID:abcdlzy,项目名称:webshell-manager,代码行数:27,代码来源:CASignCert.php

示例3: createKeys

 protected function createKeys()
 {
     $rsa = new Crypt_RSA();
     $keypair = $rsa->createKey(2048);
     $this['private_key'] = preg_replace("/\r/", "", $keypair['privatekey']);
     $this['public_key'] = preg_replace("/\r/", "", $keypair['publickey']);
 }
开发者ID:Krassmus,项目名称:LehrMarktplatz,代码行数:7,代码来源:LernmarktplatzIdentity.php

示例4:

 function generate_key_pair($user_id)
 {
     $rsa = new Crypt_RSA();
     $keypair = $rsa->createKey();
     update_user_meta($user_id, "magic_sig_public_key", $keypair['publickey']);
     update_user_meta($user_id, "magic_sig_private_key", $keypair['privatekey']);
 }
开发者ID:pfefferle,项目名称:google-code,代码行数:7,代码来源:magicsig.php

示例5: generateAndAdd

 function generateAndAdd()
 {
     $rsa = new \Crypt_RSA();
     $rsa->setPublicKeyFormat(CRYPT_RSA_PUBLIC_FORMAT_OPENSSH);
     $this->set($rsa->createKey());
     $this->save();
 }
开发者ID:romaninsh,项目名称:dokku_alt,代码行数:7,代码来源:Access.php

示例6: createPrivateKey

 public function createPrivateKey($sslCnfPath)
 {
     $rsa = new Crypt_RSA();
     $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
     $keyPair = $rsa->createKey();
     return array('public' => $keyPair['publickey'], 'private' => $keyPair['privatekey']);
 }
开发者ID:niel,项目名称:spotweb,代码行数:7,代码来源:Services_Signing_Php.php

示例7: generate_key_pair

function generate_key_pair($user_id)
{
    $rsa = new Crypt_RSA();
    $keypair = $rsa->createKey();
    // FIXME: Should we put 'ocf_' before these?
    set_custom_field($user_id, 'magic_sig_public_key', $keypair['publickey']);
    set_custom_field($user_id, 'magic_sig_private_key', $keypair['privatekey']);
}
开发者ID:Warbo,项目名称:ocportal-salmon,代码行数:8,代码来源:magicsig.php

示例8: 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

示例9: generateKeyPair

 /**
  * Generate an SSH public / private key pair
  * @return array
  */
 public static function generateKeyPair()
 {
     $publickey = '';
     $privatekey = '';
     $rsa = new \Crypt_RSA();
     $rsa->setPublicKeyFormat(CRYPT_RSA_PUBLIC_FORMAT_OPENSSH);
     extract($rsa->createKey());
     $publickey = str_replace('phpseclib-generated-key', self::SSH_KEY_NAME, $publickey);
     return array($publickey, $privatekey);
 }
开发者ID:primat,项目名称:deployer-org,代码行数:14,代码来源:SshTask.php

示例10: createKeys

 private static function createKeys()
 {
     $rsa = new \Crypt_RSA();
     $aKeys = $rsa->createKey(512);
     if (empty($aKeys)) {
         throw new \Exception("Key generation failed...");
     }
     $sKeyPath = __DIR__ . "/../../AppBundle/Resources/private/api/keys/server/";
     file_put_contents($sKeyPath . "private.key", $aKeys['privatekey']);
     file_put_contents($sKeyPath . "public.key", $aKeys['publickey']);
 }
开发者ID:RockKeeper,项目名称:control-bundle,代码行数:11,代码来源:InstallHelper.php

示例11: createKeys

 public static function createKeys()
 {
     $rsa = new \Crypt_RSA();
     $aKeys = $rsa->createKey(512);
     if (empty($aKeys)) {
         throw new \Exception("Key generation failed...");
     }
     $sAppPath = self::$_container->get('kernel')->getRootDir();
     $sKeyPath = $sAppPath . "/../vendor/slashworks/control-bundle/src/Slashworks/AppBundle/Resources/private/api/keys/server/";
     file_put_contents($sKeyPath . "private.key", $aKeys['privatekey']);
     file_put_contents($sKeyPath . "public.key", $aKeys['publickey']);
 }
开发者ID:slashworks,项目名称:control-bundle,代码行数:12,代码来源:InstallHelper.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: newKeys

 private function newKeys()
 {
     set_time_limit(30000);
     $path = get_include_path();
     $rsa = new Crypt_RSA();
     $keys = $rsa->createKey($this->bits);
     set_include_path($path);
     if ($this->type == "filegallery") {
         FileGallery\File::filename($this->certName)->setParam("description", $this->certName)->replace(json_encode($keys));
     }
     if ($this->type == "file") {
         file_put_contents("temp/" . $this->certName, json_encode($keys));
     }
     return $keys;
 }
开发者ID:rjsmelo,项目名称:tiki,代码行数:15,代码来源:tikisecure.php

示例14: creat_public_key

 public function creat_public_key()
 {
     $oldIncludePath = get_include_path();
     $include = realpath(dirname(__FILE__));
     set_include_path($include . DIRECTORY_SEPARATOR . 'CryptLib');
     include_once 'Crypt/RSA.php';
     $rsa = new Crypt_RSA();
     $rsa->setPrivateKeyFormat(CRYPT_RSA_PRIVATE_FORMAT_PKCS1);
     $rsa->setPublicKeyFormat(CRYPT_RSA_PUBLIC_FORMAT_PKCS1);
     //define('CRYPT_RSA_EXPONENT', 65537);
     //define('CRYPT_RSA_SMALLEST_PRIME', 64); // makes it so multi-prime RSA is used
     $a = $rsa->createKey();
     // == $rsa->createKey(1024) where 1024 is the key size
     return $a;
 }
开发者ID:congnn,项目名称:betoja,代码行数:15,代码来源:My_encrypt.php

示例15: testSaveSPKAC

 public function testSaveSPKAC()
 {
     $privKey = new Crypt_RSA();
     extract($privKey->createKey());
     $privKey->loadKey($privatekey);
     $x509 = new File_X509();
     $x509->setPrivateKey($privKey);
     $x509->setChallenge('...');
     $spkac = $x509->signSPKAC();
     $this->assertInternalType('array', $spkac);
     $this->assertInternalType('string', $x509->saveSPKAC($spkac));
     $x509 = new File_X509();
     $x509->setPrivateKey($privKey);
     $spkac = $x509->signSPKAC();
     $this->assertInternalType('array', $spkac);
     $this->assertInternalType('string', $x509->saveSPKAC($spkac));
 }
开发者ID:anthrotech,项目名称:laravel_sample,代码行数:17,代码来源:SPKACTest.php


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