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


PHP Crypt_RSA::decrypt方法代码示例

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


在下文中一共展示了Crypt_RSA::decrypt方法的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: asymmetricDecrypt

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

示例3: login

 /**
  * Log user in
  */
 function login()
 {
     $params = $this->request->get('params', false);
     if ($params) {
         $rsa = new Crypt_RSA();
         $my_pub_key = ConfigOptions::getValue('frosso_auth_my_pub_key');
         $my_pri_key = ConfigOptions::getValue('frosso_auth_my_pri_key');
         $rsa->loadKey($my_pri_key);
         $decrypted_params = $rsa->decrypt($params);
         if ($decrypted_params) {
             list($email, $token, $timestamp) = explode(';', $decrypted_params);
             if ($email && $token && $timestamp) {
                 if ($token == ConfigOptions::getValue('frosso_auth_my_pri_token') && time() - 60 * 10 < $timestamp && $timestamp < time() + 60 * 10) {
                     Authentication::useProvider('FrossoProvider', false);
                     Authentication::getProvider()->initialize(array('sid_prefix' => AngieApplication::getName(), 'secret_key' => AngieApplication::getAdapter()->getUniqueKey()));
                     Authentication::getProvider()->authenticate($email);
                 } else {
                     $this->response->forbidden();
                 }
                 // token non valido
             } else {
                 $this->response->badRequest(array('message' => 'Parametri non '));
             }
             // parametri non validi
         } else {
             $this->response->badRequest(array('message' => 'Parametri non validi'));
         }
     } else {
         $this->response->badRequest(array('message' => 'Parametri non settati'));
     }
     // parametri non settati
 }
开发者ID:NaszvadiG,项目名称:ACModules,代码行数:35,代码来源:FrossoAuthController.class.php

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

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

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

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

示例8: decrypt

 function decrypt($cipher)
 {
     if ($this->hasKeys() == false) {
         return "";
     }
     $keys = $this->getKeys();
     $rsa = new Crypt_RSA();
     $rsa->loadKey($keys->publickey);
     $rsa->loadKey($keys->privatekey);
     return $rsa->decrypt($cipher);
 }
开发者ID:rjsmelo,项目名称:tiki,代码行数:11,代码来源:tikisecure.php

示例9: rsa_decrypt

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

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

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

function decrypt_message($message, $asym_key)
{
    $rsa = new Crypt_RSA();
    $rij = new Crypt_Rijndael();
    // Extract the Symmetric Key
    $len = substr($message, 0, 3);
    $len = hexdec($len);
    $sym_key = substr($message, 0, $len);
    //Extract the encrypted message
    $message = substr($message, 3);
    $ciphertext = substr($message, $len);
    $ciphertext = base64_decode($ciphertext);
    // Decrypt the encrypted symmetric key
    $rsa->loadKey($asym_key);
    $sym_key = base64_decode($sym_key);
    $sym_key = $rsa->decrypt($sym_key);
    // Decrypt the message
    $rij->setKey($sym_key);
    $plaintext = $rij->decrypt($ciphertext);
    return $message;
}
开发者ID:Zeeshan-Afzal92,项目名称:RSA-Cryptography,代码行数:21,代码来源:encrypt_decrypt.php

示例13: tk_decrypt

function tk_decrypt($key, $crypt_data, $skip_openssl_check = FALSE)
{
    $decrypt;
    if ($skip_openssl_check == TRUE || function_exists('openssl_public_decrypt') == TRUE) {
        // Use OpenSSL if it is working
        openssl_public_decrypt($crypt_data, $decrypt, $key, OPENSSL_PKCS1_PADDING);
        if (empty($decrypt) == TRUE) {
            // OpenSSL can't decrypt this for some reason
            // Use built in Code instead
            require_once 'RSA.php';
            $rsa = new Crypt_RSA();
            $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
            $rsa->loadKey($key);
            $decrypt = $rsa->decrypt($crypt_data);
        }
    } else {
        // Use built in Code
        require_once 'RSA.php';
        $rsa = new Crypt_RSA();
        $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
        $rsa->loadKey($key);
        $decrypt = $rsa->decrypt($crypt_data);
    }
    return $decrypt;
}
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:25,代码来源:function.php

示例14: local_check_pin

 /**
  * Return if PIN for card is valid
  *
  * @param  string $card
  * @param  int $pin
  * @return ITS SECRET
  */
 public function local_check_pin($card, $pin, $key)
 {
     global $DB, $CFG;
     try {
         if (empty($pin) || strlen($pin) < 4) {
             throw new Exception('PIN is invalid.');
         }
         $rsa = new Crypt_RSA();
         $rsa->setPassword(get_config('quiz_nitroreportpdf', 'passkey'));
         $rsa->loadKey(get_config('quiz_nitroreportpdf', 'privkey'));
         $ckey = $rsa->decrypt(base64_decode(rawurldecode($key)));
         $token = (new Parser())->parse((string) $ckey);
         if (!$token) {
             throw new Exception('The data is invalid or time expired.');
         }
         if ($token->getClaim('iss') != "NITROCARD" || $token->getClaim('aud') != "NITROCARD" || strtotime("now") >= $token->getClaim('exp') || $token->getClaim('login') != get_config('quiz_nitroreportpdf', 'apilogin') || $token->getClaim('pass') != get_config('quiz_nitroreportpdf', 'apipass') || $token->getClaim('md5') != md5(get_config('quiz_nitroreportpdf', 'pubkey'))) {
             throw new Exception('The data is invalid or time expired.');
         }
         if (empty(strip_tags($card)) || substr(strip_tags($card), 0, 9) != "NITROCARD" || strlen(strip_tags($card)) < 98 || strlen(strip_tags($card)) > 108) {
             throw new Exception('NitroCard is invalid');
         }
         $card_e = explode('.', strip_tags($card));
         if (count($card_e) != 5) {
             throw new Exception('NitroCard is invalid');
         }
         $reqdb = $DB->count_records_sql('SELECT count(fullcardid) FROM {nitrocard_cards} WHERE fullcardid="' . strip_tags($card) . '"');
         if ($reqdb == 1) {
             //local
             $reqdb2 = $DB->count_records_sql('SELECT count(fullcardid) FROM {nitrocard_cards} WHERE fullcardid="' . strip_tags($card) . '" AND pin="' . strip_tags($pin) . '"');
             if ($reqdb2 == 1) {
                 $token_allow = (new Builder())->setIssuer('NITROCARD')->setAudience('NITROCARD')->setId(substr(md5(strtotime("now")), 0, 10), true)->setIssuedAt(time())->setExpiration(time() + 60)->set('NITROCARDID', $card)->getToken();
                 $rsa = new Crypt_RSA();
                 $rsa->setPassword(get_config('quiz_nitroreportpdf', 'passkey'));
                 $rsa->loadKey(get_config('quiz_nitroreportpdf', 'privkey'));
                 $enc = base64_encode($rsa->encrypt($token_allow));
                 $loginurl = $CFG->wwwroot . '/login/index.php';
                 if (!empty($CFG->alternateloginurl)) {
                     $loginurl = $CFG->alternateloginurl;
                 }
                 $loginurl .= '?provider=nitrocard&auth=' . rawurlencode('' . $enc);
                 return $loginurl;
             } else {
                 $DB->execute('UPDATE {nitrocard_cards} SET count_to_blocked=count_to_blocked+1 WHERE fullcardid="' . strip_tags($card) . '"');
                 $reqdb3 = $DB->get_record_sql('SELECT count_to_blocked FROM {nitrocard_cards} WHERE fullcardid="' . strip_tags($card) . '"');
                 if ($reqdb3->count_to_blocked >= 3) {
                     $DB->execute('UPDATE {nitrocard_cards} SET blocked="1" WHERE fullcardid="' . strip_tags($card) . '"');
                     throw new Exception('NitroCard is blocked.');
                 }
                 throw new Exception('PIN is incorrect.');
             }
         } else {
             //remote
         }
     } catch (Exception $e) {
         setError($e->getMessage());
     }
     return false;
 }
开发者ID:nitro2010,项目名称:nitro_moodle_plugins,代码行数:65,代码来源:api.php

示例15: decrypt_message

 public function decrypt_message($message)
 {
     if (!$this->key_local) {
         throw new Exception('No decryption key has been set');
     }
     $this->ensure_crypto_loaded();
     $rsa = new Crypt_RSA();
     $rij = new Crypt_Rijndael();
     // Extract the Symmetric Key
     $len = substr($message, 0, 3);
     $len = hexdec($len);
     $sym_key = substr($message, 3, $len);
     // Extract the encrypted message
     $cipherlen = substr($message, $len + 3, 16);
     $cipherlen = hexdec($cipherlen);
     $ciphertext = substr($message, $len + 19, $cipherlen);
     $ciphertext = base64_decode($ciphertext);
     // Decrypt the encrypted symmetric key
     $rsa->loadKey($this->key_local);
     $sym_key = base64_decode($sym_key);
     $sym_key = $rsa->decrypt($sym_key);
     // Decrypt the message
     $rij->setKey($sym_key);
     return $rij->decrypt($ciphertext);
 }
开发者ID:beyond-z,项目名称:braven,代码行数:25,代码来源:class-udrpc.php


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