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


PHP Crypt_RSA::encrypt方法代码示例

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


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

示例1: asymmetricEncrypt

 /**
  * Encrypts data using RSA
  * @param String $data Data to encrypt
  * @return String
  */
 public function asymmetricEncrypt($data)
 {
     if (!$this->isRsaInitialized) {
         $this->initAsymmetric();
     }
     return Base64::UrlEncode($this->rsa->encrypt($data));
 }
开发者ID:tiagogoddard,项目名称:cryptoapi,代码行数:12,代码来源:RsaAesCryptography.php

示例2: RSA_Encrypt

function RSA_Encrypt($plaintext, $publicKey)
{
    $rsa = new Crypt_RSA();
    $rsa->loadKey($publicKey);
    $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
    return base64_encode($rsa->encrypt($plaintext));
}
开发者ID:ClementNerma,项目名称:NearOS,代码行数:7,代码来源:user.php

示例3: encrypt_message

function encrypt_message($plaintext, $asym_key, $key_length = 150)
{
    $rsa = new Crypt_RSA();
    $rij = new Crypt_Rijndael();
    // Generate Random Symmetric Key
    $sym_key = crypt_random_string($key_length);
    // Encrypt Message with new Symmetric Key
    $rij->setKey($sym_key);
    $ciphertext = $rij->encrypt($plaintext);
    $ciphertext = base64_encode($ciphertext);
    // Encrypted the Symmetric Key with the Asymmetric Key
    $rsa->loadKey($asym_key);
    $sym_key = $rsa->encrypt($sym_key);
    // Base 64 encode the symmetric key for transport
    $sym_key = base64_encode($sym_key);
    $len = strlen($sym_key);
    // Get the length
    $len = dechex($len);
    // The first 3 bytes of the message are the key length
    $len = str_pad($len, 3, '0', STR_PAD_LEFT);
    // Zero pad to be sure.
    // Concatinate the length, the encrypted symmetric key, and the message
    $message = $len . $sym_key . $ciphertext;
    return $message;
}
开发者ID:Zeeshan-Afzal92,项目名称:RSA-Cryptography,代码行数:25,代码来源:encrypt_decrypt.php

示例4: testSuppliedKey

    public function testSuppliedKey()
    {
        // $ openssl genrsa -out key.pem 512
        $generatedKey = <<<EOL
-----BEGIN RSA PRIVATE KEY-----
MIIBOwIBAAJBAKihibtt92M6A/z49CqNcWugBd3sPrW3HF8TtKANZd1EWQ/agZ65
H2/NdL8H6zCgmKpYFTqFGwlYrnWrsbD1UxcCAwEAAQJAWX5pl1Q0D7Axf6csBg1M
3V5u3qlLWqsUXo0ZtjuGDRgk5FsJOA9bkxfpJspbr2CFkodpBuBCBYpOTQhLUc2H
MQIhAN1stwI2BIiSBNbDx2YiW5IVTEh/gTEXxOCazRDNWPQJAiEAwvZvqIQLexer
TnKj7q+Zcv4G2XgbkhtaLH/ELiA/Fh8CIQDGIC3M86qwzP85cCrub5XCK/567GQc
GmmWk80j2KpciQIhAI/ybFa7x85Gl5EAS9F7jYy9ykjeyVyDHX0liK+V1355AiAG
jU6zr1wG9awuXj8j5x37eFXnfD/p92GpteyHuIDpog==
-----END RSA PRIVATE KEY-----
EOL;
        // $ openssl rsa -pubout -in key.pem
        $publickey = <<<EOL
-----BEGIN PUBLIC KEY-----
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKihibtt92M6A/z49CqNcWugBd3sPrW3
HF8TtKANZd1EWQ/agZ65H2/NdL8H6zCgmKpYFTqFGwlYrnWrsbD1UxcCAwEAAQ==
-----END PUBLIC KEY-----
EOL;
        $rsa = new Crypt_RSA();
        $rsa->loadKey($publickey);
        $str = "123";
        $enc = $rsa->encrypt($str);
        //        echo "encoded=",bin2hex($enc),"\n";
        $rsa->loadKey($generatedKey);
        $dec = $rsa->decrypt($enc);
        $this->assertEquals($str, $dec, "Basic Encrypt/Decrypt with Supplied key.");
    }
开发者ID:haya-sann,项目名称:INTER-Mediator,代码行数:30,代码来源:RSA_Test.php

示例5: encryptChallenge

function encryptChallenge($publicKey, $rnd)
{
    $rsa = new Crypt_RSA();
    $rsa->loadKey($publicKey);
    $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
    $ciphertext = $rsa->encrypt($rnd);
    return base64_encode($ciphertext);
}
开发者ID:EDDA-BA,项目名称:webEdda,代码行数:8,代码来源:crypto.php

示例6: getEncryptedPassword

 private function getEncryptedPassword()
 {
     $key = $this->getRSAKey();
     $rsa = new Crypt_RSA();
     $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
     $rsa->loadKey(['n' => new Math_BigInteger($key->publickey_mod, 16), 'e' => new Math_BigInteger($key->publickey_exp, 16)]);
     return ['code' => base64_encode($rsa->encrypt($this->pass)), 'time' => $key->timestamp];
 }
开发者ID:Top-Cat,项目名称:EscrowTF,代码行数:8,代码来源:User.php

示例7: criptografar

function criptografar($texto)
{
    $rsa = new Crypt_RSA();
    $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
    $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
    $rsa->loadKey($_SESSION['chave_publica']);
    return base64_encode($rsa->encrypt($texto));
}
开发者ID:carlsonsantana,项目名称:SecureHTML,代码行数:8,代码来源:include.php

示例8: RSAEncrypt

function RSAEncrypt($text, $pem)
{
    $x509 = new File_X509();
    $rsa = new Crypt_RSA();
    $x509->loadX509($pem);
    $rsa->loadKey($x509->getPublicKey());
    $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
    return bin2hex($rsa->encrypt($text));
}
开发者ID:abcdlzy,项目名称:webshell-manager,代码行数:9,代码来源:common.php

示例9: encrypt

 function encrypt($data = "")
 {
     $keys = $this->getKeys();
     $path = get_include_path();
     $rsa = new Crypt_RSA();
     $rsa->loadKey($keys->publickey);
     set_include_path($path);
     return $rsa->encrypt($data);
 }
开发者ID:rjsmelo,项目名称:tiki,代码行数:9,代码来源:tikisecure.php

示例10: isValidKey

 /**
  * Return true if $pub_k and $pri_k encode and decode the same text
  * 
  * @param String $pub_k
  * @param String $pri_k
  * @return boolean
  */
 static function isValidKey($pub_k, $pri_k)
 {
     $plaintext = 'pippopippo';
     $rsa = new Crypt_RSA();
     $rsa->loadKey($pub_k);
     $ciphertext = $rsa->encrypt($plaintext);
     $rsa->loadKey($pri_k);
     return $plaintext == $rsa->decrypt($ciphertext);
 }
开发者ID:NaszvadiG,项目名称:ACModules,代码行数:16,代码来源:FrossoAuthModel.class.php

示例11: index

 /**
  * Index action
  */
 function index()
 {
     $rsa = new Crypt_RSA();
     $rsa->loadKey(ConfigOptions::getValue('frosso_auth_my_pub_key'));
     $text = 'frosso@remedia.it;' . ConfigOptions::getValue('frosso_auth_my_pri_token', false) . ';' . time();
     $crypt = $rsa->encrypt($text);
     echo '<textarea cols="200">' . $crypt . "</textarea>";
     echo '<br/><textarea cols="200">' . urlencode($crypt) . "</textarea>";
     $this->response->badRequest();
 }
开发者ID:NaszvadiG,项目名称:ACModules,代码行数:13,代码来源:FrossoTestingController.class.php

示例12: encrypt

 function encrypt($data = "")
 {
     $keys = $this->getKeys();
     $path = get_include_path();
     set_include_path("lib/phpseclib/");
     require_once 'Crypt/RSA.php';
     $rsa = new Crypt_RSA();
     $rsa->loadKey($keys->privatekey);
     set_include_path($path);
     return $rsa->encrypt($data);
 }
开发者ID:railfuture,项目名称:tiki-website,代码行数:11,代码来源:tikisecure.php

示例13: rsa_encrypt

 public function rsa_encrypt($plain_text, $publicKey)
 {
     $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->loadKey($publicKey);
     $ciphertext = $rsa->encrypt($plain_text);
     set_include_path($oldIncludePath);
     return base64_encode($ciphertext);
 }
开发者ID:congnn,项目名称:betoja,代码行数:12,代码来源:My_encrypt.php

示例14: verify

 /**
  * Attempts to use the key with current passkey thus making sure that
  * passphrase works
  */
 function verify()
 {
     $rsa = new Crypt_RSA();
     $rsa->loadKey($this['notes']);
     $encrypt = $rsa->encrypt('test');
     $pack = $this->app->getPackingKey();
     if ($pack) {
         $rsa->setPassword($pack);
     }
     $rsa->loadKey($this['data']);
     $text = $rsa->decrypt($encrypt);
     // Missmatch here shouldn't happen. It would rather throw
     // exception during decrypt();
     return $text == 'test' ? 'Successful' : 'Descryption missmatch';
 }
开发者ID:kmattimo,项目名称:dokku-alt-manager,代码行数:19,代码来源:Keychain.php

示例15: publicEncrypt

 public function publicEncrypt($data, $publicKey)
 {
     $this->requireLibrary();
     $rsa = new Crypt_RSA();
     $rsa->setEncryptionMode(CRYPT_RSA_SIGNATURE_PKCS1);
     $rsa->loadKey($publicKey, CRYPT_RSA_PUBLIC_FORMAT_PKCS1);
     $errorCatcher = new MWP_Debug_ErrorCatcher();
     $errorCatcher->register();
     $encrypted = $rsa->encrypt($data);
     $error = $errorCatcher->yieldErrorMessage(true);
     if ($encrypted === false && $error !== null) {
         throw new MWP_Worker_Exception(MWP_Worker_Exception::PHPSECLIB_ENCRYPT_ERROR, "Error while trying to use OpenSSL to encrypt a message.", array('error' => $error));
     }
     return $encrypted;
 }
开发者ID:tconte252,项目名称:haute-inhabit,代码行数:15,代码来源:PhpSecLibCrypter.php


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