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


PHP Buffer::slice方法代碼示例

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


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

示例1: signCompact

 /**
  * @param PrivateKeyInterface $privateKey
  * @param Buffer $messageHash
  * @param RbgInterface $rbg
  * @return CompactSignature
  * @throws \Exception
  */
 public function signCompact(Buffer $messageHash, PrivateKeyInterface $privateKey, RbgInterface $rbg = null)
 {
     $sigStr = '';
     $recid = 0;
     $ret = \secp256k1_ecdsa_sign_compact($messageHash->getBinary(), $privateKey->getBuffer()->getBinary(), $sigStr, $recid);
     if ($ret === 1) {
         $sigStr = new Buffer($sigStr);
         return new CompactSignature($sigStr->slice(0, 32)->getInt(), $sigStr->slice(32, 32)->getInt(), $recid, $privateKey->isCompressed());
     }
     throw new \Exception('Unable to create compact signature');
 }
開發者ID:rubensayshi,項目名稱:bitcoin-php,代碼行數:18,代碼來源:Secp256k1.php

示例2: parseIpBuffer

 /**
  * @param Buffer $ip
  * @return string
  * @throws \Exception
  */
 private function parseIpBuffer(Buffer $ip)
 {
     $end = $ip->slice(12, 4);
     return implode(".", array_map(function ($int) {
         return unpack("C", $int)[1];
     }, str_split($end->getBinary(), 1)));
 }
開發者ID:tokenly,項目名稱:bitcoin-p2p-php,代碼行數:12,代碼來源:NetworkAddressTimestampSerializer.php

示例3: entropyToWords

 /**
  * @param Buffer $entropy
  * @return array
  * @throws \Exception
  */
 public function entropyToWords(Buffer $entropy)
 {
     $math = $this->ecAdapter->getMath();
     $n = count($this->wordList);
     $wordArray = [];
     $chunks = $entropy->getSize() / 4;
     for ($i = 0; $i < $chunks; $i++) {
         $x = $entropy->slice(4 * $i, 4)->getInt();
         $index1 = $math->mod($x, $n);
         $index2 = $math->mod($math->add($math->div($x, $n), $index1), $n);
         $index3 = $math->mod($math->add($math->div($math->div($x, $n), $n), $index2), $n);
         $wordArray[] = $this->wordList->getWord($index1);
         $wordArray[] = $this->wordList->getWord($index2);
         $wordArray[] = $this->wordList->getWord($index3);
     }
     return $wordArray;
 }
開發者ID:sbwdlihao,項目名稱:bitcoin-php,代碼行數:22,代碼來源:ElectrumMnemonic.php

示例4: publicKeyFromBuffer

 /**
  * @param Buffer $publicKey
  * @return PublicKeyInterface
  * @throws \Exception
  */
 public function publicKeyFromBuffer(Buffer $publicKey)
 {
     $compressed = $publicKey->getSize() == PublicKey::LENGTH_COMPRESSED;
     $xCoord = $publicKey->slice(1, 32)->getInt();
     return new PublicKey($this, $this->getGenerator()->getCurve()->getPoint($xCoord, $compressed ? $this->recoverYfromX($xCoord, $publicKey->slice(0, 1)->getHex()) : $publicKey->slice(33, 32)->getInt()), $compressed);
 }
開發者ID:sbwdlihao,項目名稱:bitcoin-php,代碼行數:11,代碼來源:EcAdapter.php


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