當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Crypt_Math_BigInteger::powmod方法代碼示例

本文整理匯總了PHP中Zend_Crypt_Math_BigInteger::powmod方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Crypt_Math_BigInteger::powmod方法的具體用法?PHP Zend_Crypt_Math_BigInteger::powmod怎麽用?PHP Zend_Crypt_Math_BigInteger::powmod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Crypt_Math_BigInteger的用法示例。


在下文中一共展示了Zend_Crypt_Math_BigInteger::powmod方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: computeSecretKey

 /**
  * Compute the shared secret key based on the public key received from the
  * the second party to this transaction. This should agree to the secret
  * key the second party computes on our own public key.
  * Once in agreement, the key is known to only to both parties.
  * By default, the function expects the public key to be in binary form
  * which is the typical format when being transmitted.
  *
  * If you need the binary form of the shared secret key, call
  * getSharedSecretKey() with the optional parameter for Binary output.
  *
  * @param string $publicKey
  * @param string $type
  * @param string $output
  * @throws Zend_Crypt_DiffieHellman_Exception
  * @return mixed
  */
 public function computeSecretKey($publicKey, $type = self::NUMBER, $output = self::NUMBER)
 {
     if ($type == self::BINARY) {
         $publicKey = $this->_math->fromBinary($publicKey);
     }
     if (!preg_match("/^\\d+\$/", $publicKey)) {
         throw new Zend_Crypt_DiffieHellman_Exception('invalid parameter; not a positive natural number');
     }
     if (function_exists('openssl_dh_compute_key') && self::$useOpenssl !== false) {
         $this->_secretKey = openssl_dh_compute_key($publicKey, $this->getPublicKey());
     } else {
         $this->_secretKey = $this->_math->powmod($publicKey, $this->getPrivateKey(), $this->getPrime());
     }
     return $this->getSharedSecretKey($output);
 }
開發者ID:kobmaki,項目名稱:icingaweb2,代碼行數:32,代碼來源:DiffieHellman.php


注:本文中的Zend_Crypt_Math_BigInteger::powmod方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。