richardds/big-integer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

richardds/big-integer

Composer 安装命令:

composer require richardds/big-integer

包简介

Library for big integer manipulation

README 文档

README

PHP OOP library for fast big integer manipulation made as a wrapper around GMP library. The library is not converting the numbers into a string but uses GMP resources, which comes with significant speed improvement compared to other libraries. The library has no external dependencies.

General requirements

  • php-7.2 and higher
  • php-gmp library

How to install GMP on Apline Linux

RUN apk add --update --no-cache gmp
RUN apk add --update --no-cache --virtual .phpize-deps $PHPIZE_DEPS autoconf g++ make gmp-dev && \
    docker-php-ext-install gmp && \
    apk del .phpize-deps $PHPIZE_DEPS autoconf g++ make gmp-dev

Examples

Majority of the methods accept BigInteger object, string or int. The BigInteger object uses GMP resource. Therefore, there is no slow string conversion on every operation.

use Richardds\BigInteger\BigInteger;
use Richardds\BigInteger\Utils as BigIntegerUtils;

$g = BigInteger::fromInt(2);
$e = BigInteger::fromString("<big_integer>");
$m = BigInteger::fromString("<big_integer>");
$c = $g->powMod($e, $m);

$p = BigInteger::fromBuffer("<buffer>");
$z = BigInteger::fromString("<big_integer>");

$x = $g->powMod($p, $m)
       ->mul($z->sub(BigInteger::one()))
       ->mod($m);

$a = BigInteger::fromString("<big_integer>");
$b = BigInteger::fromString("<big_integer>");
$gcd = $a->gcd($b);
$gcd = BigIntegerUtils::gcd($a, $b);

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固