2017 © Pedro Peláez
 

project base62

Simple base 62 encoder/decoder

image

kurl/base62

Simple base 62 encoder/decoder

  • Tuesday, May 6, 2014
  • by breenie
  • Repository
  • 1 Watchers
  • 1 Stars
  • 260 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

A simple base 62 encoder/decoder

Does what it says on the tin. Converts base 10 numbers to base 62 encoded strings and back again. If the GMP extension is installed this will be used. If not the pure PHP implementation will encode/decode the values. Without actually doing any kind of performance tests I can only assume the GMP driver is better/faster/more precise., (*1)

While there are other great base 62 encoders in composer, none reflected the gmp_strval implementation preferring to use a dictionary [0-9a-zA-z] whilst GMP uses [0-9A-Za-z]., (*2)

Installation

Add the following to your composer.json and update/install:, (*3)

{
    "require": {
        "kurl/base62": "1.0.*"
    }
}

Encode

<?php

use Kurl\Maths\Encode\Base62;

$encoder = new Base62();
echo $encoder->encode(35);

// Z

Decode

<?php

use Kurl\Maths\Encode\Base62;

$encoder = new Base62();
echo $encoder->encode('a');

// 36

Using the pure PHP encoder

If for whatever reason you want to use the pure PHP driver by default:, (*4)

<?php

use Kurl\Maths\Encode\Driver\PurePhpEncoder;

$encoder = new Base62();
$encoder->setDriver(new PurePhpEncoder());
echo $encoder->encode('a');

// 36

Why "Maths"?

I'm British and that is how we spell it., (*5)

The Versions

06/05 2014

dev-master

9999999-dev

Simple base 62 encoder/decoder

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

06/05 2014

dev-develop

dev-develop

Simple base 62 encoder/decoder

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

06/05 2014

1.0.0

1.0.0.0

Simple base 62 encoder/decoder

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires