• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP openssl_private_decrypt函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了openssl_private_decrypt函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 <[email protected]>
  */
 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


示例16: checkUser

 function checkUser()
 {
     $rec = $this->_decodePostData();
     $private = file_get_contents(CONFIG_PATH . 'keys/private.key');
     $key = base64_decode($rec['data']->key);
     if (!openssl_private_decrypt($key, $key, openssl_pkey_get_private($private))) {
         exit;
     } else {
         $key = json_decode($key);
         $this->key = $key->asskey;
         // global key access in this controller
         //login in parent app
         $sys = new Model\Sysuser();
         $user = $sys->getLogin($key->login, $key->password);
         if ($user === false) {
             exit(json_encode(['ret' => 'no']));
         }
         //create new user (delete if exists)
         $this->model->createUser($user->ID, $user->NAME, $this->key);
         //user x group status
         $ugs = $this->model->getUserGroupStatus($user->ID);
         $user = array_merge(['ID' => $user->ID, 'NAME' => $user->NAME], $ugs);
         //send
         $this->_sendEncriptedData($user);
     }
 }
开发者ID:pedra,项目名称:limp,代码行数:26,代码来源:user.php


示例17: decrypt

 function decrypt($text)
 {
     $decryptedText = "";
     $text = base64_decode($text);
     openssl_private_decrypt($text, $decryptedText, $this->StringPrivateKey);
     return $decryptedText;
 }
开发者ID:frankpaul142,项目名称:chaide,代码行数:7,代码来源:RSAEncryption.php


示例18: decrypt

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


示例19: encode

 public function encode($data)
 {
     $core = $this->core;
     $extensions = $core->extensions;
     // Client
     $connIn = $core->getInDuplex();
     // Server
     $connOut = $core->getOutDuplex();
     $data = $this->encodeHeader($data);
     // ECDHE
     if ($core->cipherSuite->isECDHEEnabled()) {
         $publicKeyLen = Core::_unpack('C', $data[0]);
         $publicKey = substr($data, 1, $publicKeyLen);
         $preMaster = $extensions->call('Curve', 'calculatePreMaster', null, $publicKey);
     } else {
         // https://tools.ietf.org/html/rfc5246#section-7.4.7.1
         // Get a Premaster Secret
         $preMasterLen = Core::_unpack('n', $data[0] . $data[1]);
         $encPreMaster = substr($data, 2, $preMasterLen);
         $privateKey = $core->getConfig('private_key');
         openssl_private_decrypt($encPreMaster, $preMaster, $privateKey);
         $vMajor = Core::_unpack('C', $preMaster[0]);
         $vMinor = Core::_unpack('C', $preMaster[1]);
         list($vMajor2, $vMinor2) = $core->getVersion();
         if ($vMajor != $vMajor2 || $vMinor != $vMinor) {
             throw new TLSAlertException(Alert::create(Alert::BAD_RECORD_MAC), "Invalid protocol version in PreMaster {$vMajor} <=> {$vMajor2}, {$vMinor} <=> {$vMinor2}");
         }
     }
     $this->setKeys($preMaster, $connOut, $connIn);
 }
开发者ID:rnaga,项目名称:php-tls,代码行数:30,代码来源:ClientKeyExchange.php


示例20: decryptPassword

function decryptPassword($input)
{
    $config = $GLOBALS['config'];
    if ($config['rsa_modulus'] != '' && $config['rsa_exponent'] != '' && $config['rsa_key'] != '' && isset($_SESSION['crypt_key'])) {
        if (substr($input, 0, 5) == "enc: ") {
            $input = substr($input, 5);
            $res = openssl_pkey_get_private($config['rsa_key'], $config['rsa_passphrase']);
            openssl_private_decrypt(hex2bin($input), $plaintext, $res);
            $plaintext = utf8_encode($plaintext);
            //loop through current session login keys and try all of them that haven't expired
            foreach ($_SESSION['crypt_key'] as $arrayKey => $key_array) {
                //key_array is array(time key was generated, hexadecimal key)
                if (time() - $key_array[0] > 5 * 60) {
                    //delete keys older than 5 minutes
                    //shouldn't take that long to login anyway!
                    unset($_SESSION['crypt_key'][$arrayKey]);
                } else {
                    $crypt_key = $key_array[1];
                    //first part of plaintext should be equal to crypt key
                    if (substr($plaintext, 0, strlen($crypt_key)) == $crypt_key) {
                        return substr($plaintext, strlen($crypt_key));
                    }
                }
            }
            //none of the keys above worked, either forgery or expired form
            return "";
        } else {
            return $input;
        }
    } else {
        return $input;
    }
}
开发者ID:uakfdotb,项目名称:oneapp,代码行数:33,代码来源:crypto.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP openssl_private_encrypt函数代码示例发布时间:2022-05-15
下一篇:
PHP openssl_pkey_new函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap