当前位置: 首页>>代码示例>>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;未经允许,请勿转载。