Giter VIP home page Giter VIP logo

base58-php-ext's Introduction

improved PHP library

Base58 PHP extension

Build Status Build status

PHP extension for base58 encoding and decoding using the Bitcoin alphabet.

Using this extension is about 100 times faster than using userspace functions.

Requirements

  • PHP 7.x or 8.x

Installation

The extension is available from pecl.

pecl install base58-beta

Manual build

Instead of installing this extension from pecl, you can build it manually

phpize
./configure --with-base58
make
make install

Add the following line to your php.ini

extension=base58.so

Functions

base58_encode

Base58 encode a string.

string base58_encode(string $data)

Triggers an E_WARNING and returns false if string can't be encoded.

base58_encode

Decode a base58 encoded string.

string base58_decode(string $data)

Triggers an E_WARNING and returns false if string can't be decoded.

Caveat

To encode a hash, make sure you're using the raw hash and not a hexidecimal string.

$rawHash = hash('sha256', 'some string', true); // The `true` makes the function return a raw hash
$encodedHash = base58_encode($rawHash);

Benchmark

The extension is run in test Base58ExtEvent. The Base58BCMathEvent and Base58GMPEvent tests use the StephenHill\Base58 PHP library.

StephenHill\Benchmarks\Base16Event
    Method Name    Iterations    Average Time      Ops/second
    ------------  ------------  --------------    -------------
    encodeBase16: [10,000    ] [0.0000001919985] [5,208,374.51881]
    decodeBase16: [10,000    ] [0.0000004031897] [2,480,222.34049]


StephenHill\Benchmarks\Base58BCMathEvent
    Method Name    Iterations    Average Time      Ops/second
    ------------  ------------  --------------    -------------
    encodeBase58: [10,000    ] [0.0000484058857] [20,658.64482]
    decodeBase58: [10,000    ] [0.0000523419857] [19,105.12157]


StephenHill\Benchmarks\Base58ExtEvent
    Method Name    Iterations    Average Time      Ops/second
    ------------  ------------  --------------    -------------
    encodeBase58: [10,000    ] [0.0000003235340] [3,090,865.14370]
    decodeBase58: [10,000    ] [0.0000003539085] [2,825,588.79008]


StephenHill\Benchmarks\Base58GMPEvent
    Method Name    Iterations    Average Time      Ops/second
    ------------  ------------  --------------    -------------
    encodeBase58: [10,000    ] [0.0000255326509] [39,165.53757]
    decodeBase58: [10,000    ] [0.0000418104410] [23,917.47075]


StephenHill\Benchmarks\Base64Event
    Method Name    Iterations    Average Time      Ops/second
    ------------  ------------  --------------    -------------
    encodeBase64: [10,000    ] [0.0000003066778] [3,260,750.99122]
    decodeBase64: [10,000    ] [0.0000003187656] [3,137,100.97233]

base58-php-ext's People

Contributors

jasny avatar jbboehr avatar mburns83 avatar remicollet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

base58-php-ext's Issues

config.w32 is missing from 1.0.1

For some reason, config.w32 is missing in package.xml, and as such is not contained in the tarballs. Thus, it's not possible to buld base58 1.0.1 on Windows.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.