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

PHP openssl_public_decrypt函数代码示例

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

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



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

示例1: decryptPublic

function decryptPublic($path, $cText)
{
    $fcontents = file_get_contents($path);
    $publicKey = openssl_pkey_get_public($fcontents);
    openssl_public_decrypt($cText, $decrypted, $publicKey);
    return $decrypted;
}
开发者ID:joshin85,项目名称:login,代码行数:7,代码来源:encrypt.php


示例2: decrypt

 /**
  * Decrypts $data using this public key.
  * @param mixed $data
  * @return string
  * @throws DecryptionFailedException
  */
 public function decrypt($data)
 {
     if (!openssl_public_decrypt($data, $decrypted, $this->keyResource)) {
         throw new DecryptionFailedException('Failed decrypting the data with this public key.');
     }
     return $decrypted;
 }
开发者ID:ntthanh,项目名称:crypto,代码行数:13,代码来源:PublicKey.class.php


示例3: rsaPublicDecrypt

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


示例4: check

 /**
  * Método que verifica el código de autorización de folios
  * @return =true si está ok el XML cargado
  * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
  * @version 2015-10-30
  */
 public function check()
 {
     // validar firma del SII sobre los folios
     $firma = $this->getFirma();
     $idk = $this->getIDK();
     if (!$firma or !$idk) {
         return false;
     }
     $pub_key = \sasco\LibreDTE\Sii::cert($idk);
     if (!$pub_key or openssl_verify($this->xml->getFlattened('/AUTORIZACION/CAF/DA'), base64_decode($firma), $pub_key) !== 1) {
         \sasco\LibreDTE\Log::write(\sasco\LibreDTE\Estado::FOLIOS_ERROR_FIRMA, \sasco\LibreDTE\Estado::get(\sasco\LibreDTE\Estado::FOLIOS_ERROR_FIRMA));
         return false;
     }
     // validar clave privada y pública proporcionada por el SII
     $private_key = $this->getPrivateKey();
     if (!$private_key) {
         return false;
     }
     $plain = md5(date('U'));
     if (!openssl_private_encrypt($plain, $crypt, $private_key)) {
         \sasco\LibreDTE\Log::write(\sasco\LibreDTE\Estado::FOLIOS_ERROR_ENCRIPTAR, \sasco\LibreDTE\Estado::get(\sasco\LibreDTE\Estado::FOLIOS_ERROR_ENCRIPTAR));
         return false;
     }
     $public_key = $this->getPublicKey();
     if (!$public_key) {
         return false;
     }
     if (!openssl_public_decrypt($crypt, $plain_firmado, $public_key)) {
         \sasco\LibreDTE\Log::write(\sasco\LibreDTE\Estado::FOLIOS_ERROR_DESENCRIPTAR, \sasco\LibreDTE\Estado::get(\sasco\LibreDTE\Estado::FOLIOS_ERROR_DESENCRIPTAR));
         return false;
     }
     return $plain === $plain_firmado;
 }
开发者ID:Tutorializame,项目名称:libredte-lib,代码行数:39,代码来源:Folios.php


示例5: publicKeyDecrypt

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


示例6: check_license

    public static function check_license($license)
    {
        $signature = $license['Signature'];
        unset($license['Signature']);
        uksort($license, "strcasecmp");
        $total = '';
        foreach ($license as $value) {
            $total .= $value;
        }
        $key_raw = <<<EOD
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCtl7Dgf4x0fi0lXfws7Cq/lk0d
TIEXnCu8PBMep0mtRia9WEJ8N53d+8gbuAcMzb4sW6MVOzTEKYrmtq/DTbiaXKiJ
o6osz5KgBjbcGrCzKKvk8uQuTZWusqp69LQfTYSwxwJIp45kl0g8yalewGUtpYuu
yWXBBsw7Z909BpTLBQIDAAAD
-----END PUBLIC KEY-----
EOD;
        $key = openssl_get_publickey($key_raw);
        openssl_public_decrypt(base64_decode($signature), $checkDigest, $key);
        $digest = sha1($total, true);
        if ($digest === $checkDigest) {
            return true;
        }
        return false;
    }
开发者ID:macauley,项目名称:Dash-Annotations,代码行数:25,代码来源:DashLicenseUtil.php


示例7: decrypt

 /**
  * Decrypt data using this public key. Only data encrypted with
  * the private 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_public_decrypt($data, $decrypted, $this->_hdl)) {
         throw new CryptoException('Could not decrypt data', OpenSslUtil::getErrors());
     }
     return $decrypted;
 }
开发者ID:xp-framework,项目名称:security,代码行数:15,代码来源:PublicKey.class.php


示例8: dec_pub

 function dec_pub($dat)
 {
     list($cry,$str) = array_map('base64_decode',explode(':',$dat));
     $res = openssl_get_publickey($this->pub);
     openssl_public_decrypt($cry,$key,$res);
     $ret = $this->dec_sym($key,$str);
     return trim($ret);
 }
开发者ID:spinit,项目名称:osy,代码行数:8,代码来源:Crypt.php


示例9: decrypt

 public function decrypt($data, $pubkey)
 {
     $rs = '';
     if (@openssl_public_decrypt($data, $rs, $pubkey) === FALSE) {
         return NULL;
     }
     return $rs;
 }
开发者ID:visionzk,项目名称:phalapi,代码行数:8,代码来源:Pri2Pub.php


示例10: decrypt

 /**
  * @param string $encrypted
  *
  * @return string
  */
 public function decrypt(string $encrypted) : string
 {
     $status = openssl_public_decrypt($encrypted, $decrypted, $this);
     if (!$status) {
         throw new RuntimeException('Decrypt failed');
     }
     return $decrypted;
 }
开发者ID:blar,项目名称:openssl,代码行数:13,代码来源:PublicKey.php


示例11: decrypt1

 public function decrypt1($data)
 {
     if (openssl_public_decrypt(base64_decode($data), $decrypted, $this->pubkey)) {
         $data = $decrypted;
     } else {
         $data = '';
     }
     return $data;
 }
开发者ID:wuwenhan,项目名称:huoqiwang,代码行数:9,代码来源:Appcheck.php


示例12: verifyAesKeyFileEncrypted

 function verifyAesKeyFileEncrypted()
 {
     $pubk = $this->readIrsPublicKey(true);
     $decrypted = "";
     if (!openssl_public_decrypt($this->aesEncrypted, $decrypted, $pubk)) {
         throw new \Exception("Failed to decrypt aes key for verification purposes");
     }
     return $decrypted == $this->am->getAesIv();
 }
开发者ID:shadiakiki1986,项目名称:fatca-ides-php,代码行数:9,代码来源:RsaManager.php


示例13: publicDecrypt

 public static function publicDecrypt($pubKey, $data)
 {
     if (!strstr($pubKey, 'BEGIN PUBLIC KEY')) {
         $pubKey = self::lengthenPublicKey($pubKey);
     }
     $key_resource = openssl_get_publickey($pubKey);
     openssl_public_decrypt(base64_decode($data), $cleartext, $key_resource);
     return $cleartext;
 }
开发者ID:kemosabhay,项目名称:Lightning,代码行数:9,代码来源:Encryption.php


示例14: decryptByPublicKey

 public static function decryptByPublicKey($data)
 {
     $pu_key = openssl_pkey_get_public(file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/system/modules/pay/lib/cbjpay/config/wy_rsa_public_ley.pem'));
     //这个函数可用来判断公钥是否是可用的,可用返回资源id Resource id
     $decrypted = "";
     $data = base64_decode($data);
     openssl_public_decrypt($data, $decrypted, $pu_key);
     //公钥解密
     return $decrypted;
 }
开发者ID:ping199143,项目名称:1ydb,代码行数:10,代码来源:RSAUtils.php


示例15: decrypt

 /**
  * Decrypts the given data.
  *
  * @param string $encryptedData The data to decrypt.
  * @param int $padding The padding to use for decryption.
  * @return string Returns the decrypted data.
  * @since 0.3
  */
 public function decrypt(string $encryptedData, int $padding = OPENSSL_PKCS1_PADDING) : string
 {
     OpenSSL::resetErrors();
     if (openssl_public_decrypt($encryptedData, $decrypted, $this->resource, $padding) === false) {
         // @codeCoverageIgnoreStart
         throw new OpenSSLException(OpenSSL::getErrors(), 'Could not decrypt the given data with this public key.');
         // @codeCoverageIgnoreEnd
     }
     return $decrypted;
 }
开发者ID:norseblue,项目名称:sikker,代码行数:18,代码来源:PublicKey.php


示例16: decryptByPublicKey

 public static function decryptByPublicKey($data)
 {
     $pu_key = openssl_pkey_get_public(file_get_contents(APP_ROOT_PATH . 'system/payment/jdpay/config/wy_rsa_public_key_production.pem'));
     //这个函数可用来判断公钥是否是可用的,可用返回资源id Resource id
     $decrypted = "";
     $data = base64_decode($data);
     openssl_public_decrypt($data, $decrypted, $pu_key);
     //公钥解密
     return $decrypted;
 }
开发者ID:myjavawork,项目名称:sanxin-fangwei,代码行数:10,代码来源:RSAUtils.php


示例17: decrypt

 public function decrypt($text)
 {
     if ($this->public_key) {
         $ret = '';
         if (openssl_public_decrypt(base64_decode($text), $ret, $this->public_key)) {
             return $ret;
         }
     }
     return null;
 }
开发者ID:zhaoshengloveqingqing,项目名称:Ci,代码行数:10,代码来源:encryptor.php


示例18: decryptByPublicKey

 public static function decryptByPublicKey($data)
 {
     $pu_key = openssl_pkey_get_public(file_get_contents(dirname(__DIR__) . '/configure/wy_rsa_public_key.pem'));
     //这个函数可用来判断公钥是否是可用的,可用返回资源id Resource id
     $decrypted = "";
     $data = base64_decode($data);
     openssl_public_decrypt($data, $decrypted, $pu_key);
     //公钥解密
     return $decrypted;
 }
开发者ID:zrone,项目名称:JDproject,代码行数:10,代码来源:RSAUtils.php


示例19: decrypt

 /**
  * Rsa解密
  * @param string $data 需解密的数据
  * @return null|string 解密结果
  */
 public function decrypt($data)
 {
     $this->_makesure_provider();
     $data = base64_decode($data);
     if ($this->isPrivate) {
         $r = openssl_private_decrypt($data, $decrypted, $this->keyProvider, OPENSSL_PKCS1_PADDING);
     } else {
         $r = openssl_public_decrypt($data, $decrypted, $this->keyProvider, OPENSSL_PKCS1_PADDING);
     }
     return $r ? $decrypted : null;
 }
开发者ID:john123951,项目名称:sweet.security.rsa,代码行数:16,代码来源:KeyWorker.php


示例20: publicDecrypt

 public function publicDecrypt($message)
 {
     $key = \Clips\get_default($this, 'publicKey');
     if ($key) {
         $ret = '';
         if (openssl_public_decrypt(base64_decode($message), $ret, $key)) {
             return $ret;
         }
     }
     return false;
 }
开发者ID:guitarpoet,项目名称:clips-tool,代码行数:11,代码来源:Encryptor.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP openssl_public_encrypt函数代码示例发布时间:2022-05-15
下一篇:
PHP openssl_private_encrypt函数代码示例发布时间: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