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

PHP openssl_pkey_get_public函数代码示例

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

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



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

示例1: post_id_new1_new2_handler

 public function post_id_new1_new2_handler()
 {
     global $FANNIE_PLUGIN_SETTINGS, $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']);
     $ret = array('errors' => '');
     $safe = $this->safetyCheck();
     if ($safe !== true) {
         $ret['errors'] = $safe;
     } else {
         $keyfile = realpath(dirname(__FILE__) . '/keys/public.key');
         $pubkey = openssl_pkey_get_public(file_get_contents($keyfile));
         $try = openssl_public_encrypt($this->new1, $encrypted, $pubkey);
         if (!$try) {
             $ret['errors'] = 'Error occurred during encryption';
         } else {
             if ($this->new1 !== $this->new2) {
                 $ret['errors'] = 'New values do not match';
             } else {
                 $model = new GumTaxIdentifiersModel($dbc);
                 $model->card_no($this->id);
                 $model->encryptedTaxIdentifier($encrypted);
                 $model->maskedTaxIdentifier(substr($this->new1, -4));
                 $model->save();
             }
         }
     }
     echo json_encode($ret);
     return false;
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:29,代码来源:GumTaxIdPage.php


示例2: getResource

 /**
  *  {@inheritdoc}
  */
 public function getResource()
 {
     if (!($resource = openssl_pkey_get_public($this->keyPEM))) {
         throw new KeyFormatException(sprintf('Fail to convert key into resource: %s', openssl_error_string()));
     }
     return $resource;
 }
开发者ID:acmephp,项目名称:acmephp,代码行数:10,代码来源:PublicKey.php


示例3: getKey

 /**
  * getPrivateKey
  * @return resource|FALSE
  * @see http://cn2.php.net/manual/en/function.openssl-get-publickey.php
  */
 private function getKey()
 {
     if ($this->_keyInstance === false) {
         $this->_keyInstance = openssl_pkey_get_public($this->key);
     }
     return $this->_keyInstance;
 }
开发者ID:xjflyttp,项目名称:php-rsa,代码行数:12,代码来源:RsaPublic.php


示例4: ValidateGooglePlaySignature

function ValidateGooglePlaySignature($receipt, $signature)
{
    $publicGoogleKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAt+zLT00kiP/8iHZrvBwbAOIibC6qhGW9Mt6FHFHh+uJN5+wIYWKfsWS8cU9383iJ6Q0zL2Gk7UQtZvp9ug3yCzWkTADWzepO8rm0+gBuv7OcrIq5TF5qIS4qXrmTg1VkloJb0C4OP9IPqRpa9VKa1nWIa1VbLY2U4U7vgQIcLBIGL+5d2/qhjj4UeK3seWvY8XxHh9CElxMAmaOWU6aNUSon0G7r68gwx15hMOoVy4ICeKrGyn8XibTiruYwXHwBJ6JQNYzWRtJPEF1DL1TLev/DneVVoFgrc6ZnZMZGwlnYLKn0AolCTfq2c1GRUj/FI/wd3Rcm6lHeN3pbkmb1GwIDAQAB";
    $receipt = trim($receipt);
    $signature = trim($signature);
    //Create an RSA key compatible with openssl_verify from our Google Play sig
    $key = "-----BEGIN PUBLIC KEY-----\n" . chunk_split($publicGoogleKey, 64, "\n") . '-----END PUBLIC KEY-----';
    $key = openssl_pkey_get_public($key);
    //print $signature;print_r(openssl_pkey_get_details($key)); exit();
    if ($key == false) {
        return $ret = 100;
    }
    //Signature should be in binary format, but it comes as BASE64.
    $signature = base64_decode($signature);
    //Verify the signature
    $result = openssl_verify($receipt, $signature, $key, OPENSSL_ALGO_SHA1);
    //print $result . ' / ' . $receipt . ' / ' . $signature . ' / ' . $key;exit();
    if ($result == 1) {
        $ret = 1;
    } elseif ($result == 0) {
        $ret = 0;
    } else {
        $ret = 2;
    }
    return $ret;
}
开发者ID:letmefly,项目名称:tools_script,代码行数:26,代码来源:google_helper.php


示例5: loadPEM

 /**
  * @param $data
  *
  * @throws \Exception
  * @throws \FG\ASN1\Exception\ParserException
  *
  * @return array
  */
 private function loadPEM($data)
 {
     $res = openssl_pkey_get_private($data);
     if (false === $res) {
         $res = openssl_pkey_get_public($data);
     }
     if (false === $res) {
         throw new \Exception('Unable to load the key');
     }
     $details = openssl_pkey_get_details($res);
     if (!array_key_exists('rsa', $details)) {
         throw new \Exception('Unable to load the key');
     }
     foreach ($details['rsa'] as $key => $value) {
         $value = Base64Url::encode($value);
         if ($key === 'dmp1') {
             $this->dp = $value;
         } elseif ($key === 'dmq1') {
             $this->dq = $value;
         } elseif ($key === 'iqmp') {
             $this->qi = $value;
         } else {
             $this->{$key} = $value;
         }
     }
 }
开发者ID:rwx-zwx-awx,项目名称:jose,代码行数:34,代码来源:RSAKey.php


示例6: publicKeyEncrypt

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


示例7: __construct

 public function __construct($headers = null, $body = null)
 {
     $config = Payplug::getConfig();
     if (is_null($config)) {
         throw new ParametersNotSetException();
     }
     if (is_null($body)) {
         $body = file_get_contents("php://input");
     }
     if (is_null($headers)) {
         $headers = getallheaders();
     }
     $headers = array_change_key_case($headers, CASE_UPPER);
     $signature = base64_decode($headers['PAYPLUG-SIGNATURE']);
     $publicKey = openssl_pkey_get_public($config->payplugPublicKey);
     $isValid = openssl_verify($body, $signature, $publicKey, OPENSSL_ALGO_SHA1);
     if (!$isValid) {
         throw new InvalidSignatureException();
     }
     $data = json_decode($body, true);
     $this->amount = $data['amount'];
     $this->customData = $data['custom_data'];
     $this->customer = $data['customer'];
     $this->email = $data['email'];
     $this->firstName = $data['first_name'];
     $this->idTransaction = $data['id_transaction'];
     $this->lastName = $data['last_name'];
     $this->order = $data['order'];
     $this->origin = $data['origin'];
     $this->state = $data['state'];
 }
开发者ID:q0821,项目名称:esportshop,代码行数:31,代码来源:IPN.php


示例8: __construct

 public function __construct($certificate)
 {
     if (!extension_loaded('openssl')) {
         throw new OpenSSLExtensionNotLoadedException('The openssl module is not loaded.');
     }
     $this->keyResource = openssl_pkey_get_public($certificate);
 }
开发者ID:ntthanh,项目名称:crypto,代码行数:7,代码来源:PublicKey.class.php


示例9: fetchPublicKey

 /**
  * Fetches public key from the remote certificate
  *
  * @param $url
  * @return string|false
  */
 protected function fetchPublicKey($url)
 {
     $cache = \Yii::$app->cache;
     $cacheKey = 'paypal-public-key-' . md5($url);
     $publicKey = $cache->get($cacheKey);
     if ($publicKey) {
         return $publicKey;
     }
     // trying to fetch certificate
     $cert = @file_get_contents($url);
     if (!$cert) {
         return false;
     }
     $key = openssl_pkey_get_public($cert);
     if (!$key) {
         return false;
     }
     $keyData = openssl_pkey_get_details($key);
     $result = ArrayHelper::getValue($keyData, 'key', false);
     if (!$result) {
         return false;
     }
     $cache->add($cacheKey, $result);
     return $result;
 }
开发者ID:yii-dream-team,项目名称:yii2-paypal,代码行数:31,代码来源:WebHookAction.php


示例10: encrypt

 /**
  * {@inheritdoc}
  */
 public function encrypt($data, $key)
 {
     $publicKey = openssl_pkey_get_public($key);
     openssl_public_encrypt($data, $messageEncrypted, $publicKey);
     openssl_free_key($publicKey);
     return $messageEncrypted;
 }
开发者ID:claudusd,项目名称:cryptography,代码行数:10,代码来源:EncryptionRSA.php


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


示例12: getKeyResource

 /**
  * Converts a string representation of a key into an OpenSSL resource
  *
  * @param string|resource $key
  * @param string          $password
  * @return resource OpenSSL key resource
  */
 protected function getKeyResource($key, $password = null)
 {
     if (is_resource($key)) {
         return $key;
     }
     return openssl_pkey_get_public($key) ?: openssl_pkey_get_private($key, $password);
 }
开发者ID:jonasvr,项目名称:lockedornot,代码行数:14,代码来源:PublicKey.php


示例13: __construct

 function __construct($clientcrt, $clientkey, $clientpw = NULL, $logging = false)
 {
     if (is_bool($logging)) {
         $this->logging = $logging;
     }
     if (!openssl_pkey_get_private(is_file($clientkey) ? "file://" . $clientkey : $clientkey, $clientpw)) {
         $this->log("Invalid client private key.", true);
     }
     if (!openssl_pkey_get_public(is_file($clientcrt) ? "file://" . $clientcrt : $clientcrt)) {
         $this->log("Invalid client public key.", true);
     }
     $this->log("Certificate / key looks valid.");
     $handle = curl_init();
     curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($handle, CURLOPT_HEADER, true);
     curl_setopt($handle, CURLOPT_USERAGENT, sprintf("StartSSL-PHP-API/%s", self::VERSION));
     curl_setopt($handle, CURLOPT_URL, $this->authUrl);
     curl_setopt($handle, CURLOPT_SSLCERT, $clientcrt);
     curl_setopt($handle, CURLOPT_SSLKEY, $clientkey);
     if (!is_null($clientpw)) {
         curl_setopt($handle, CURLOPT_SSLKEYPASSWD, $clientpw);
     }
     $this->log("Authenticating...");
     $result = curl_exec($handle);
     preg_match('/^Set-Cookie: (MyStartSSLCookie=.*)$/m', $result, $matches);
     if (isset($matches[1])) {
         $this->cookie = $matches[1];
         $this->log("User authenticated.");
     } else {
         $this->log("Unable to authenticate. Check certificate/key.", true);
     }
 }
开发者ID:TheDJVG,项目名称:StartSSL-PHP-API,代码行数:32,代码来源:startssl.class.php


示例14: getPublicKey

 /**
  * @return resource
  */
 protected function getPublicKey()
 {
     if (is_null($this->publicKey)) {
         throw new ParameterNotFoundException("'publicKey' in JWTEncoder");
     }
     return openssl_pkey_get_public('file://' . $this->publicKey);
 }
开发者ID:HallOfBets,项目名称:HOBTokenBundle,代码行数:10,代码来源:JWTEncoder.php


示例15: userAuthAction

 /**
  * @Rest\Post("/users/auth")
  * @param unknown $request
  */
 public function userAuthAction()
 {
     $data = $this->getRequest()->get("data");
     $stringDecrypted = "";
     openssl_private_decrypt(base64_decode($data), $stringDecrypted, openssl_pkey_get_private(file_get_contents(__DIR__ . "/keys/server/private_key_server.pem")));
     $jsonDecrypted = json_decode($stringDecrypted);
     $entityManager = $this->container->get('fos_user.user_manager');
     $user = $entityManager->findUserByUsername($jsonDecrypted->username);
     $encoder_service = $this->get('security.encoder_factory');
     $encoder = $encoder_service->getEncoder($user);
     $encoded_pass = $encoder->isPasswordValid($user->getPassword(), $jsonDecrypted->password, $user->getSalt());
     $token = 0;
     if ($encoded_pass) {
         $currentTime = time();
         $tokenTime = $currentTime + 86400;
         // on day
         $user->setTokenExpiresAt($tokenTime);
         $clearToken = $user->getUsername() . '@' . $tokenTime;
         $shaToken = sha1($clearToken);
         $user->setToken($shaToken);
         $stringCrypted = "";
         $json = "{'token':'" . $clearToken . "'}";
         openssl_public_encrypt($json, $stringCrypted, openssl_pkey_get_public(file_get_contents(__DIR__ . "/keys/server/public_key_mobile.pem")));
         $token = base64_encode($stringCrypted);
         return json_encode(["data" => $token]);
     } else {
         return false;
     }
 }
开发者ID:secureOptimisation,项目名称:WSOptiCloud,代码行数:33,代码来源:RestUserController.php


示例16: get_keys

 static public function get_keys($login,$full_name) {
   $CA_CERT = base_url()."data/key/CA_DOC.csr";
   $CA_KEY  = base_url()."data/key/CA_DOC_priv.key";
   $config = array(
     "private_key_type"=>OPENSSL_KEYTYPE_RSA,
     "private_key_bits"=>512
   );
   $res = openssl_pkey_new($config);
   $privKey = '';
   openssl_pkey_export($res,$privKey);
   $arr = array(
     "organizationName" => "Фізична особа",
     "organizationalUnitName" => "Фізична особа",
     "commonName" => $full_name,
     "UID" => $login,
     "countryName" => "UA"
   );
   $csr = openssl_csr_new($arr,$privKey);
   $cert = openssl_csr_sign($csr,file_get_contents($CA_CERT),file_get_contents($CA_KEY),730);
   openssl_x509_export($cert,$str_cert);
   $public_key = openssl_pkey_get_public($str_cert);
   $public_key_details = openssl_pkey_get_details($public_key);
   $public_key_string = $public_key_details['key'];
   return array('private'=>$privKey,'cert'=>$str_cert,'public'=>$public_key_string);
 }
开发者ID:2ovob4ehko,项目名称:doc,代码行数:25,代码来源:Enc.php


示例17: webid_claim

function webid_claim()
{
    $r = array('uri' => array());
    if (isset($_SERVER['SSL_CLIENT_CERT'])) {
        $pem = $_SERVER['SSL_CLIENT_CERT'];
        if ($pem) {
            $x509 = openssl_x509_read($pem);
            $pubKey = openssl_pkey_get_public($x509);
            $keyData = openssl_pkey_get_details($pubKey);
            if (isset($keyData['rsa'])) {
                if (isset($keyData['rsa']['n'])) {
                    $r['m'] = strtolower(array_pop(unpack("H*", $keyData['rsa']['n'])));
                }
                if (isset($keyData['rsa']['e'])) {
                    $r['e'] = hexdec(array_shift(unpack("H*", $keyData['rsa']['e'])));
                }
            }
            $d = openssl_x509_parse($x509);
            if (isset($d['extensions']) && isset($d['extensions']['subjectAltName'])) {
                foreach (explode(', ', $d['extensions']['subjectAltName']) as $elt) {
                    if (substr($elt, 0, 4) == 'URI:') {
                        $r['uri'][] = substr($elt, 4);
                    }
                }
            }
        }
    }
    return $r;
}
开发者ID:sgml,项目名称:rww.io,代码行数:29,代码来源:webid.lib.php


示例18: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     //
     //Log::info('$request=<' . $request . '>');
     if ($request->isMethod('post')) {
         $bodyContent = $request->getContent();
         //Log::info('$bodyContent=<' . $bodyContent . '>');
         $bodyJson = json_decode($bodyContent);
         $keyPath = $this->keyRoot_ . $bodyJson->token . '/pubKey.pem';
         $fp = fopen($keyPath, 'r');
         $pubKeyMem = fread($fp, 8192);
         fclose($fp);
         $pubkeyid = openssl_pkey_get_public($pubKeyMem);
         $token = $bodyJson->token;
         $sign = $bodyJson->sign;
         $ok = openssl_verify($token, hex2bin($sign), $pubkeyid, "sha256");
         openssl_free_key($pubkeyid);
         if ($ok == 1) {
             $profilePath = $this->keyRoot_ . $bodyJson->token . '/profile';
             //Log::info('$bodyJson->payload=<' . json_encode($bodyJson->payload) . '>');
             file_put_contents($profilePath, json_encode($bodyJson->payload));
             return response()->json(['status' => 'success']);
         } else {
             return response()->json(['status' => 'failure']);
         }
     }
 }
开发者ID:WatorVapor,项目名称:account,代码行数:33,代码来源:ProfileController.php


示例19: publicKey

 public static function publicKey($uri, $ts)
 {
     if (self::publicExists($uri, $ts)) {
         return openssl_pkey_get_public('file://' . self::_basePath() . '/' . md5($uri . $ts) . '.pub');
     }
     return false;
 }
开发者ID:neel,项目名称:bong,代码行数:7,代码来源:secure.php


示例20: verify

 /**
  * 验签
  *
  * @param string $data
  * @param string $sign
  * @param string $pem
  * @return bool 验签状态
  */
 private function verify($data, $sign)
 {
     $p = openssl_pkey_get_public(file_get_contents($this->chinaums_config['publickKey']));
     $verify = openssl_verify($data, hex2bin($sign), $p);
     openssl_free_key($p);
     return $verify > 0;
 }
开发者ID:yishuixm,项目名称:online-pay,代码行数:15,代码来源:ChinaumsNotify.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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