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


PHP Crypt_RSA::setEncryptionMode方法代码示例

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


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

示例1: RSADecrypt

function RSADecrypt($ciphertext, $privateKey)
{
    $rsad = new Crypt_RSA();
    $rsad->loadKey($privateKey);
    $rsad->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
    return $rsad->decrypt(hex2bin($ciphertext));
}
开发者ID:abcdlzy,项目名称:webshell-manager,代码行数:7,代码来源:common.php

示例2: initRsa

 protected function initRsa($publicKeyFile)
 {
     if (!file_exists($publicKeyFile) || !is_readable($publicKeyFile)) {
         throw new \Exception('Public key file does not exist or is not readable.');
     }
     $public_key = file_get_contents($publicKeyFile);
     $this->rsa = new \Crypt_RSA();
     $x509 = new \File_X509();
     $x509->loadX509($public_key);
     $this->rsa->loadKey($x509->getPublicKey());
     $this->rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
     $this->rsa->setHash('sha1');
 }
开发者ID:amegatron,项目名称:cryptoapi,代码行数:13,代码来源:CryptoApiHelper.php

示例3: CryptRSA

 /**
  * @return \Crypt_RSA|null
  */
 public static function CryptRSA()
 {
     if (null === \RainLoop\Utils::$RSA) {
         if (!\defined('_phpseclib_')) {
             \set_include_path(\get_include_path() . PATH_SEPARATOR . APP_VERSION_ROOT_PATH . 'app/libraries/phpseclib');
             define('_phpseclib_', true);
         }
         if (!\class_exists('Crypt_RSA', false)) {
             include_once 'Crypt/RSA.php';
             \defined('CRYPT_RSA_MODE') || \define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_INTERNAL);
         }
         if (\class_exists('Crypt_RSA')) {
             $oRsa = new \Crypt_RSA();
             $oRsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
             $oRsa->setPrivateKeyFormat(CRYPT_RSA_PRIVATE_FORMAT_PKCS1);
             $oRsa->setPrivateKeyFormat(CRYPT_RSA_PUBLIC_FORMAT_PKCS1);
             $sPrivateKey = \file_exists(APP_PRIVATE_DATA . 'rsa/private') ? \file_get_contents(APP_PRIVATE_DATA . 'rsa/private') : '';
             if (!empty($sPrivateKey)) {
                 $oRsa->loadKey($sPrivateKey, CRYPT_RSA_PRIVATE_FORMAT_PKCS1);
                 $oRsa->loadKey($oRsa->getPublicKey(), CRYPT_RSA_PUBLIC_FORMAT_PKCS1);
                 \RainLoop\Utils::$RSA = $oRsa;
             }
         }
     }
     return \RainLoop\Utils::$RSA;
 }
开发者ID:rikardonm,项目名称:rainloop-webmail,代码行数:29,代码来源:Utils.php

示例4: rsa

 private function rsa($public_or_private_key, $padding_mode)
 {
     $rsa = new Crypt_RSA();
     $rsa->loadKey($public_or_private_key);
     $rsa->setEncryptionMode($padding_mode);
     return $rsa;
 }
开发者ID:nask0,项目名称:jose,代码行数:7,代码来源:JWE.php

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

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

示例7: decrypt

function decrypt($privatekey, $encrypted)
{
    $rsa = new Crypt_RSA();
    $encrypted = pack('H*', $encrypted);
    $rsa->loadKey($privatekey);
    $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
    return $rsa->decrypt($encrypted);
}
开发者ID:tempbottle,项目名称:phpseclib-jsbn-rsa,代码行数:8,代码来源:index.php

示例8: descriptografar

function descriptografar($texto)
{
    $rsa = new Crypt_RSA();
    $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
    $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
    $rsa->loadKey(file_get_contents('key/rsa_private.pem'));
    return $rsa->decrypt(base64_decode($texto));
}
开发者ID:carlsonsantana,项目名称:SecureHTML,代码行数:8,代码来源:include.php

示例9: RSA_Decrypt

function RSA_Decrypt($ciphertext, $privateKey)
{
    // if $ciphertext come from pidCrypt.JS, then the result of RSA_Decrypt is in base64 format
    $rsa = new Crypt_RSA();
    $rsa->loadKey($privateKey);
    $ciphertext = str_replace(array("\r", "\n", ' '), '', $ciphertext);
    $ciphertext = base64_decode($ciphertext);
    $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
    return $rsa->decrypt($ciphertext);
}
开发者ID:ClementNerma,项目名称:NearOS,代码行数:10,代码来源:user.php

示例10: initAsymmetric

 /**
  * Initializes the RSA instance using either provided private key file or default value
  * @param String $privateKeyFile Path to private key file
  * @return mixed|void
  * @throws Exception
  */
 public function initAsymmetric($privateKeyFile = '')
 {
     if (!$privateKeyFile) {
         $privateKeyFile = app_path() . '/keys/private.key';
     }
     if (!\File::exists($privateKeyFile)) {
         \Log::error("Error reading private key file.");
         throw new \Exception("Error reading private key file.");
     }
     $this->rsaPrivateKey = \File::get($privateKeyFile);
     $rsa = new \Crypt_RSA();
     $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
     $rsa->loadKey($this->rsaPrivateKey);
     $this->rsa = $rsa;
     $this->isRsaInitialized = true;
 }
开发者ID:tiagogoddard,项目名称:cryptoapi,代码行数:22,代码来源:RsaAesCryptography.php

示例11: publicDecrypt

 public function publicDecrypt($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();
     $decrypted = $rsa->decrypt($data);
     $error = $errorCatcher->yieldErrorMessage(true);
     // "Decryption error" is generated by the library when the public key is not correct.
     if ($decrypted === false && $error !== 'Decryption error') {
         throw new MWP_Worker_Exception(MWP_Worker_Exception::PHPSECLIB_DECRYPT_ERROR, "Error while trying to use OpenSSL to decrypt a message.", array('error' => $error));
     }
     return $decrypted === false ? null : $decrypted;
 }
开发者ID:tconte252,项目名称:haute-inhabit,代码行数:16,代码来源:PhpSecLibCrypter.php

示例12: licenseKeyGen

function licenseKeyGen($userData, $privKey, $password)
{
    $rsa = new Crypt_RSA();
    $rsa->loadKey($privKey);
    $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
    $crypted = $rsa->encrypt($userData);
    // JSON->RAW Format
    $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
    $rsa->setHash('sha512');
    $signature = $rsa->sign(hash('sha512', $userData) . hash('sha512', $crypted));
    //sha512(JSON)+sha512(RAW)->RAW
    $license = ['Key1' => base64_encode($crypted), 'Key2' => base64_encode($signature)];
    $gzdata = gzencode(json_encode($license), 9);
    $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CFB);
    $iv = mcrypt_create_iv($iv_size);
    $crypted_license = $iv . mcrypt_encrypt(MCRYPT_RIJNDAEL_256, passgen($password, $iv, true), $gzdata, MCRYPT_MODE_CFB, $iv);
    return base64_encode($crypted_license);
}
开发者ID:hartmantam,项目名称:php-license-system,代码行数:18,代码来源:keyGenerator.php

示例13: encrypt

 public function encrypt()
 {
     $binaryKey = bin2hex(base64_decode(GOOGLE_DEFAULT_PUBLIC_KEY));
     $half = substr($binaryKey, 8, 256);
     $modulus = new Math_BigInteger(hex2bin($half), 256);
     $half = substr($binaryKey, 272, 6);
     $exponent = new Math_BigInteger(hex2bin($half), 256);
     $sha1 = sha1(base64_decode($googleDefaultPublicKey), true);
     $signature = "00" . bin2hex(substr($sha1, 0, 4));
     $rsa = new Crypt_RSA();
     $rsa->setPublicKeyFormat(CRYPT_RSA_PUBLIC_FORMAT_RAW);
     $rsa->loadKey(array("n" => $modulus, "e" => $exponent));
     $rsa->setPublicKey();
     $plain = "{$email}{$password}";
     $rsa->setEncryptionMode("CRYPT_RSA_ENCRYPTION_OAEP");
     $encrypted = bin2hex($rsa->encrypt($plain));
     $output = hex2bin($signature . $encrypted);
     $b64EncryptedPasswd = str_replace(array("+", "/"), array("-", "_"), mb_convert_encoding(base64_encode($output), "US-ASCII"));
     return $b64EncryptedPasswd;
 }
开发者ID:mgp25,项目名称:Google-Crypto,代码行数:20,代码来源:encrypt.php

示例14: login

 public function login($authcode = '', $twofactorcode = '')
 {
     $dologin = $this->getRSAkey();
     if ($dologin->publickey_mod && $dologin->publickey_exp && $dologin->timestamp) {
         $password = $this->config['password'];
         $rsa = new Crypt_RSA();
         $key = array('modulus' => new Math_BigInteger($dologin->publickey_mod, 16), 'publicExponent' => new Math_BigInteger($dologin->publickey_exp, 16));
         $rsa->loadKey($key, CRYPT_RSA_PUBLIC_FORMAT_RAW);
         $rsa->setPublicKey($key);
         $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
         $enc_password = base64_encode($rsa->encrypt($password));
         $login = $this->request('POST', 'https://steamcommunity.com/login/dologin/', array('password' => $enc_password, 'username' => $this->config['username'], 'twofactorcode' => $twofactorcode, 'emailauth' => $authcode, 'loginfriendlyname' => '', 'capatcha_text' => '', 'emailsteamid' => isset($this->accountdata['steamid']) ? $this->accountdata['steamid'] : '', 'rsatimestamp' => $dologin->timestamp, 'remember_login' => 'true', 'donotcache' => time()));
         $login = json_decode($login);
         if ($login->success == false) {
             if (isset($login->emailsteamid) && $login->emailauth_needed == true) {
                 if ($authcode == '') {
                     file_put_contents($this->config['datapath'] . '/logindata.json', json_encode(array('steamid' => $login->emailsteamid)));
                     $this->error('Please enter AUTHCODE available in your e-mail inbox (domain: ' . $login->emaildomain . ').');
                 } else {
                     $this->error('You enter bad authcode!');
                 }
             } else {
                 if ($login->requires_twofactor == true) {
                     if ($twofactorcode == '') {
                         $this->error('Please enter twofactorcode (mobile auth).');
                     } else {
                         $this->error('You enter bad twofactorcode!');
                     }
                 }
             }
         } else {
             preg_match_all('#g_sessionID\\s\\=\\s\\"(.*?)\\"\\;#si', $this->view('http://steamcommunity.com/id'), $matches);
             return array('steamid' => $login->transfer_parameters->steamid, 'sessionId' => $matches[1][0], 'cookies' => $this->cookiejarToString(file_get_contents('cookiejar.txt')));
         }
         return $login;
     } else {
         $this->error('Bad RSA!');
     }
     return $dologin;
 }
开发者ID:emdy,项目名称:php-steamlogin,代码行数:40,代码来源:main.php

示例15: encriptar_rsa_texto

 private function encriptar_rsa_texto($texto = "")
 {
     include 'rsa/Crypt/RSA.php';
     //pára encriptar la clave de la tc
     $rsa = new Crypt_RSA();
     $ciphered_text = FALSE;
     //if (file_exists('application/controllers/rsa/public.pem')) {
     if (file_exists('application/controllers/rsa/public_cms.pem')) {
         //se carga la 'public key'
         //$rsa->loadKey(file_get_contents('application/controllers/rsa/public.pem')); 	// public key con password "3xp4n5i0n"
         $rsa->loadKey(file_get_contents('application/controllers/rsa/public_cms.pem'));
         // public key con password "3xp4n5i0n"
         //algoritmo de encriptación
         $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
         //2
         //texto cifrado:
         $ciphertext = $rsa->encrypt($texto);
         $ciphered_text = base64_encode($ciphertext);
         //texto cifrado
         //echo "texto cifrado" . $ciphertext . "<br/>";
         //texto codificado
         //echo "base 64 encode: " . base64_encode($ciphertext) . "<br/>";
     }
     return $ciphered_text;
 }
开发者ID:heladiofog,项目名称:ecommerce_ci,代码行数:25,代码来源:suscripcion_express.php


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