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


PHP openssl_private_decrypt函数代码示例

本文整理汇总了PHP中openssl_private_decrypt函数的典型用法代码示例。如果您正苦于以下问题:PHP openssl_private_decrypt函数的具体用法?PHP openssl_private_decrypt怎么用?PHP openssl_private_decrypt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: decode

    public function decode($encrypted)
    {
        $decrypted = '';
        //        $encrypted = $_POST['merchantReciept'];
        $privateKey = <<<EOD
-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJuIUgSzNuWm3US8
0brZr/5cMSPue9f0IwUrEhka1gLlC4uQon6QjQem4TWQ8anoMKYwfYgRnCGQsbrT
KwOApwTA4Bt6dg9jKXlIE6rXqqO6g2C/uD+G2p+W4k0ZI1isuqqjjkup5ZPkNaeW
R9/961Qx3CyrWDk6n0OkzDJ6UNzLAgMBAAECgYEAh+/dv73jfVUaj7l4lZct+2MY
kA8grt7yvNGoP8j0xBLsxE7ltzkgClARBoBot9f4rUg0b3j0vWF59ZAbSDRpxJ2U
BfWEtlXWvN1V051KnKaOqE8TOkGK0PVWcc6P0JhPrbmOu9hhAN3dMu+jd7ABFKgC
4b8EIlHA8bl8po8gwAECQQDliMBTAzzyhB55FMW/pVGq9TBo2oXQsyNOjEO+rZNJ
zIwJzFrFhvuvFj7/7FekDAKmWgqpuOIk0NSYfHCR54FLAkEArXc7pdPgn386ikOc
Nn3Eils1WuP5+evoZw01he4NSZ1uXNkoNTAk8OmPJPz3PrtB6l3DUh1U/DEZjIiI
7z5igQJAFXvFNH/bFn/TMlYFZDie+jdUvpulZrE9nr52IMSyQngIq2obHN3TdMHK
R73hPhN5tAQ9d0E8uWFqZJNRHfbjHQJASY7pNV3Ov/QE0ALxqE3W3VDmJD/OjkOS
jriUPNIAwnnHBgp0OXHMCHkSYX4AHpLr1cWjARw9IKB1lBmF7+YFgQJAFqUgYj11
ioyuSf/CSotPIC7YyNEnr+TK2Ym0N/EWzqNXoOCDxDTgoWLQxM3Nfr65tWtV2097
BjCbFfbui/IyUw==
-----END PRIVATE KEY-----
EOD;
        $encrypted = base64_decode($encrypted);
        // decode the encrypted query string
        if (!openssl_private_decrypt($encrypted, $decrypted, $privateKey)) {
            die('Failed to decrypt data');
        }
        //        echo "Decrypted value: ". $decrypted;
        return $decrypted;
        //        $arr = explode('|', $decrypted);
        //        return $arr;
    }
开发者ID:lahirurangitha,项目名称:easypay_final,代码行数:32,代码来源:decrypt.php

示例2: login

 /**
  * Try to login with the e-mail address and the password provided
  * @param string $email Email of the user trying to connect
  * @param string $password Ciphered value of the password
  * @author Benjamin BALET <benjamin.balet@gmail.com>
  */
 public function login()
 {
     header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
     header('Access-Control-Allow-Credentials : true');
     header('Access-Control-Allow-Methods: GET');
     header('Content-Type:application/json');
     //Decipher the password (mind to remove the salt) and attempt to login
     $password = '';
     $keyPEM = file_get_contents('./assets/keys/private.pem', TRUE);
     $privateKey = openssl_pkey_get_private($keyPEM);
     openssl_private_decrypt(base64_decode($this->input->get('password')), $password, $privateKey, OPENSSL_PKCS1_OAEP_PADDING);
     $len_salt = strlen($this->session->userdata('salt')) * -1;
     $password = substr($password, 0, $len_salt);
     $this->load->model('users_model');
     $loggedin = $this->users_model->checkCredentialsEmail($this->input->get('email'), $password);
     //Return user's details (some fields might be empty if not logged in)
     $userDetails = new stdClass();
     $userDetails->id = $this->session->userdata('id');
     $userDetails->firstname = $this->session->userdata('firstname');
     $userDetails->lastname = $this->session->userdata('lastname');
     $userDetails->isManager = $this->session->userdata('is_manager');
     $userDetails->isAdmin = $this->session->userdata('is_admin');
     $userDetails->isHR = $this->session->userdata('is_hr');
     $userDetails->managerId = $this->session->userdata('manager');
     $userDetails->isLoggedIn = $loggedin;
     echo json_encode($userDetails);
 }
开发者ID:lahirwisada,项目名称:jorani,代码行数:33,代码来源:mobile.php

示例3: checkTANValidity

	public static function checkTANValidity ($emailId, $tanNo) {
		
		$db = DB::getInstance();
		$db->connect();

		$accountData = $db->select("ACCOUNTS", "userId = '$emailId'");
		$accountNo = $accountData["accountNo"];

		
		$fprv = fopen(PRIVATE_KEY_LOC, "r");   //please change the path of the privateKey file here
		$privateKey = fread($fprv, 512);
		fclose($fprv);
		
		$res_prv = openssl_get_privatekey($privateKey);

		openssl_private_decrypt(base64_decode($tanNo), $decrypted, $res_prv);
		
		if ($decrypted == $accountNo) {
			return true;
		}
		else
			return false;


		
	}
开发者ID:amitjoy,项目名称:Bank_of_Munchen,代码行数:26,代码来源:Account.util.php

示例4: privateKeyDecrypt

function privateKeyDecrypt($privateKey, $content)
{
    $pKey = openssl_pkey_get_private($privateKey);
    $decrypted = "";
    openssl_private_decrypt($content, $decrypted, $pKey);
    return $decrypted;
}
开发者ID:mysterin,项目名称:myutils,代码行数:7,代码来源:rsa.php

示例5: decrypt

 /**
  * Decrypt data using this private key. Only data encrypted with
  * the public key matching this key will be decryptable.
  *
  * @param   string data
  * @return  string
  * @throws  security.crypto.CryptoException if the operation fails
  */
 public function decrypt($data)
 {
     if (false === openssl_private_decrypt($data, $decrypted, $this->_hdl)) {
         throw new CryptoException('Could not decrypt data', OpenSslUtil::getErrors());
     }
     return $decrypted;
 }
开发者ID:xp-framework,项目名称:security,代码行数:15,代码来源:PrivateKey.class.php

示例6: rsaPrivateDecrypt

 /**
  *
  * 通过私钥解密 公钥加密的内容
  *
  * @param string $encryptedStr 公钥加密后的字符串
  *
  * @return string
  */
 public static function rsaPrivateDecrypt($encryptedStr)
 {
     $retData = '';
     $resourceId = self::getResourceId(self::TYPE_PRIVATE_KEY);
     openssl_private_decrypt(base64_decode($encryptedStr), $retData, $resourceId);
     return $retData;
 }
开发者ID:mikeching,项目名称:yii2-rsa,代码行数:15,代码来源:Rsa.php

示例7: unwrap

 /**
  * @param string          $encryptedCek
  * @param string|resource $key
  * @param int             $cekSizeBits
  * @param array           $header
  *
  * @return string
  */
 public function unwrap($encryptedCek, $key, $cekSizeBits, array $header)
 {
     if (false == openssl_private_decrypt($encryptedCek, $cek, $key, $this->padding)) {
         throw new JoseJwtException('Unable to decrypt CEK');
     }
     return $cek;
 }
开发者ID:tmilos,项目名称:jose-jwt,代码行数:15,代码来源:RsaAlgorithm.php

示例8: decryptMessage

function decryptMessage($crypttext, $priv_key, $passphrase = 'passphrase')
{
    $crypttext = base64_decode($crypttext);
    $res = openssl_pkey_get_private($priv_key, $passphrase);
    if ($res != false) {
        if (openssl_private_decrypt($crypttext, $text, $res)) {
            return $text;
        } else {
            $error = "";
            while ($msg = openssl_error_string()) {
                $error .= $msg . "<br />\n";
            }
            $error = __(DECRYPT_ERROR) . (DEBUG && $error != "" ? " : " . $error : "");
            throw new NewException($error, 0, false);
        }
    } else {
        $error = "";
        while ($msg = openssl_error_string()) {
            $error .= $msg . "<br />\n";
        }
        $error = "Error parsing private key" . ($error != "" ? " : " . $error : "");
        throw new NewException($error, 0, getDebugBacktrace(1));
    }
    return "";
}
开发者ID:kxopa,项目名称:WebSite-PHP,代码行数:25,代码来源:utils_openssl.inc.php

示例9: decrypt

function decrypt($data, $privateKey)
{
    // Decrypt the data using the private key
    openssl_private_decrypt($data, $decryptedData, $privateKey);
    // Return decrypted data
    return $decryptedData;
}
开发者ID:skydewellers,项目名称:OPENSSL-Cryptography,代码行数:7,代码来源:test.php

示例10: dechiffre

function dechiffre(string $text, string $txtDechiffre, string $cle)
{
    //on inclue en début de code la configuration de openssl
    include 'configurationSSL.php';
    openssl_private_decrypt($text, $txtDechiffre, $cle);
    return $txtDechiffre;
}
开发者ID:theprincy,项目名称:OpenSSLWebsite,代码行数:7,代码来源:ClePublique.php

示例11: __init

 private function __init()
 {
     if (false !== $this->__credentials) {
         return;
     }
     $privateKeyPath = getenv('HOME') . '/.ssh/dev/key_prv.pem';
     $credentialsPath = __DIR__ . DIRECTORY_SEPARATOR . 'credentials.php';
     $credentials = (require $credentialsPath);
     $text = file_get_contents($privateKeyPath);
     if (false === $text) {
         throw new \Exception("Could not load the file that contains the private key ({$privateKeyPath}).");
     }
     $privateKey = openssl_pkey_get_private($text);
     if (false === $privateKey) {
         throw new \Exception("The given path does not contain a valid private key ({$privateKeyPath}).");
     }
     $this->__credentials = array();
     foreach ($credentials as $_service => $_config) {
         $encodedUser = hex2bin($_config['user']);
         $encodedPassword = hex2bin($_config['password']);
         $class = $_config['class'];
         $user = null;
         $password = null;
         if (false === openssl_private_decrypt($encodedUser, $user, $privateKey)) {
             throw new \Exception("An error occurred while decoding the text \"{$encodedUser}\".");
         }
         if (false === openssl_private_decrypt($encodedPassword, $password, $privateKey)) {
             throw new \Exception("An error occurred while encoding the text \"{$encodedPassword}\".");
         }
         $this->__credentials[$_service] = array('class' => $class, 'user' => $user, 'password' => $password);
     }
 }
开发者ID:dbeurive,项目名称:imapconfig,代码行数:32,代码来源:SetUp.php

示例12: privDecrypt

 /**
  * 私钥解密
  */
 public static function privDecrypt($encrypted)
 {
     if (!is_string($encrypted)) {
         return null;
     }
     return openssl_private_decrypt(base64_decode($encrypted), $decrypted, self::getPrivateKey()) ? $decrypted : null;
 }
开发者ID:xinson,项目名称:yafPlus,代码行数:10,代码来源:Rsa.php

示例13: decrypt

 /**
  * {@inheritdoc}
  */
 public function decrypt($data, $key, $passphrase = '')
 {
     $privateKey = openssl_pkey_get_private($key, $passphrase);
     openssl_private_decrypt($data, $messageDecrypted, $privateKey);
     openssl_free_key($privateKey);
     return $messageDecrypted;
 }
开发者ID:claudusd,项目名称:cryptography,代码行数:10,代码来源:EncryptionRSA.php

示例14: decryptPrivate

function decryptPrivate($path, $cText)
{
    $fcontents = file_get_contents($path);
    $privateKey = openssl_pkey_get_private($fcontents, "symelosh");
    openssl_private_decrypt($cText, $decrypted, $privateKey);
    return $decrypted;
}
开发者ID:joshin85,项目名称:login,代码行数:7,代码来源:encrypt.php

示例15: decrypt

 /**
  * Decrypts RSA encrypted data using the given private key
  *
  * @throws Cipher\Exception\RuntimeException
  * @param string $encryptedData The encrypted data in binary format
  * @param string $privateKey The private key in binary format
  * @param string $password The private key passphrase
  * @param integer $padding The padding to use during decryption (of not provided object value will be used)
  * @return string The decrypted data
  */
 public function decrypt($encryptedData, $privateKey, $password = null, $padding = null)
 {
     $private_key = openssl_pkey_get_private(array($privateKey, $password));
     if (!$private_key) {
         throw new Cipher\Exception\RuntimeException("Failed to load private key");
     }
     if ($padding !== null) {
         try {
             $this->setPadding($padding);
         } catch (\Exception $e) {
             openssl_free_key($private_key);
             throw $e;
         }
     }
     switch ($this->getPadding()) {
         case self::NO_PADDING:
             $openssl_padding = OPENSSL_NO_PADDING;
             break;
         case self::OAEP_PADDING:
             $openssl_padding = OPENSSL_PKCS1_OAEP_PADDING;
             break;
     }
     $result = openssl_private_decrypt($encryptedData, $decryptedData, $private_key, $openssl_padding);
     openssl_free_key($private_key);
     if (!$result) {
         throw new Cipher\Exception\RuntimeException("Unable to Decrypt Value using provided private key");
     }
     if ($this->getPadding() == self::NO_PADDING) {
         $decryptedData = substr($decryptedData, 2);
         $start = strpos($decryptedData, 0) + 1;
         $decryptedData = substr($decryptedData, $start);
     }
     return $decryptedData;
 }
开发者ID:robertodormepoco,项目名称:zf2,代码行数:44,代码来源:RSA.php


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