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


PHP openssl_private_encrypt函数代码示例

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


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

示例1: rsaPrivateEncrypt

 /**
  * 私钥加密
  *
  * @param $dataStr
  *
  * @return string
  */
 public static function rsaPrivateEncrypt($dataStr)
 {
     $retData = '';
     $resourceId = self::getResourceId(self::TYPE_PRIVATE_KEY);
     openssl_private_encrypt($dataStr, $retData, $resourceId);
     $retData = base64_encode($retData);
     return $retData;
 }
开发者ID:mikeching,项目名称:yii2-rsa,代码行数:15,代码来源:Rsa.php

示例2: encryptPrivate

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

示例3: text_enc

  function text_enc($str,$key) {
		$fpr = fopen($key,"r");
		$pr_key = fread($fpr,1024);
		fclose($fpr);
		openssl_private_encrypt($str,$result,$pr_key);
		return $result;
	}
开发者ID:2ovob4ehko,项目名称:doc,代码行数:7,代码来源:Enc.php

示例4: privateKeyEncrypt

function privateKeyEncrypt($privateKey, $content)
{
    $piKey = openssl_pkey_get_private($privateKey);
    $encrypted = "";
    openssl_private_encrypt($content, $encrypted, $piKey);
    return base64_encode($encrypted);
}
开发者ID:mysterin,项目名称:myutils,代码行数:7,代码来源:rsa.php

示例5: encrypt

 /**
  * Encrypt data using this public key. Data will be decryptable
  * only with the matching private key.
  *
  * This method can only encrypt short data (= shorter than the key,
  * see the PHP manual). To encrypt larger values, use the seal()
  * method.
  *
  * @see     php://openssl_private_encrypt
  * @param   string data
  * @return  string
  * @throws  security.crypto.CryptoException if the operation fails
  */
 public function encrypt($data)
 {
     if (false === openssl_private_encrypt($data, $crypted, $this->_hdl)) {
         throw new CryptoException('Could not decrypt data', OpenSslUtil::getErrors());
     }
     return $crypted;
 }
开发者ID:xp-framework,项目名称:security,代码行数:20,代码来源:PrivateKey.class.php

示例6: privEncrypt

 /**
  * 私钥加密
  * @param  [type] $data [description]
  * @return [type]       [description]
  */
 public static function privEncrypt($data)
 {
     if (!is_string($data)) {
         return null;
     }
     return openssl_private_encrypt($data, $encrypted, self::getPrivateKey()) ? base64_encode($encrypted) : null;
 }
开发者ID:senlinsky,项目名称:PhpProject,代码行数:12,代码来源:RsaDecryption.php

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

示例8: enc_pri

 function enc_pri($str)
 {
     $key = uniqid();
     $res = openssl_get_privatekey($this->pri,$this->pra);
     openssl_private_encrypt($key,$cry,$res);
     $ret = $this->enc_sym($key,$str);
     return base64_encode($cry).':'.base64_encode($ret);
 }
开发者ID:spinit,项目名称:osy,代码行数:8,代码来源:Crypt.php

示例9: encrypt

 /**
  * Encrypt the given text with the private key
  *
  * @param KeyPair $key
  * @param string $plainText
  * @throws EncryptionException
  * @return string
  */
 public function encrypt(KeyPair $key, $plainText)
 {
     $success = openssl_private_encrypt($plainText, $result, $key->getPrivateKey());
     if ($success !== TRUE) {
         throw new EncryptionException('Encryption failed');
     }
     return $result;
 }
开发者ID:phpsource,项目名称:rsa-javascript-php,代码行数:16,代码来源:ModuleBackend.php

示例10: encrypt

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

示例11: privateEncrypt

 public static function privateEncrypt($privateKey, $data)
 {
     if (!strstr($privateKey, 'BEGIN PRIVATE KEY')) {
         $privateKey = self::lengthenPrivateKey($privateKey);
     }
     $key_resource = openssl_get_privatekey($privateKey);
     openssl_private_encrypt($data, $crypttext, $key_resource);
     return base64_encode($crypttext);
 }
开发者ID:kemosabhay,项目名称:Lightning,代码行数:9,代码来源:Encryption.php

示例12: encrypt1

 public function encrypt1($data)
 {
     if (openssl_private_encrypt($data, $encrypted, $this->privkey)) {
         $data = base64_encode($encrypted);
     } else {
         echo '错误';
     }
     return $data;
 }
开发者ID:wuwenhan,项目名称:huoqiwang,代码行数:9,代码来源:Appcheck.php

示例13: encrypt

 /**
  * Encrypts the given data.
  *
  * @param string $rawData The data to encrypt.
  * @param int $padding The padding to use for encryption.
  * @return string when the given data cannot be encrypted.
  */
 public function encrypt(string $rawData, int $padding = OPENSSL_PKCS1_PADDING) : string
 {
     OpenSSL::resetErrors();
     if (openssl_private_encrypt($rawData, $encrypted, $this->resource, $padding) === false) {
         // @codeCoverageIgnoreStart
         throw new OpenSSLException(OpenSSL::getErrors(), 'Could not encrypt the given data with this private key.');
         // @codeCoverageIgnoreEnd
     }
     return (string) $encrypted;
 }
开发者ID:norseblue,项目名称:sikker,代码行数:17,代码来源:PrivateKey.php

示例14: encrypt

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

示例15: encryptByPrivateKey

 public static function encryptByPrivateKey($data)
 {
     $pi_key = openssl_pkey_get_private(file_get_contents(dirname(__DIR__) . '/configure/seller_rsa_private_key.pem'));
     //这个函数可用来判断私钥是否是可用的,可用返回资源id Resource id
     $encrypted = "";
     openssl_private_encrypt($data, $encrypted, $pi_key, OPENSSL_PKCS1_PADDING);
     //私钥加密
     return base64_encode($encrypted);
     //加密后的内容通常含有特殊字符,需要编码转换下,在网络间通过url传输时要注意base64编码是否是url安全的
 }
开发者ID:zrone,项目名称:JDproject,代码行数:10,代码来源:RSAUtils.php


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