Skip to content

Latest commit

 

History

History
66 lines (49 loc) · 1.23 KB

README.md

File metadata and controls

66 lines (49 loc) · 1.23 KB

Base64Url

This is Base64Url encoder and decoder written in pure PHP.

Installation

First add this repo to composer.json:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/ieu/base64url-php"
        }
    ]
}

Then install it through composer:

composer require ieu/base64url:dev-master

Usage

base64url_encode

use function Ieu\Base64Url\base64url_encode;

// Encoding
base64url_encode("Hello, world!");

// Encoding without padding
base64url_encode("Hello, world!", false);

base64url_decode

use function Ieu\Base64Url\base64url_decode;

// Decode
base64url_decode("SGVsbG8sIHdvcmxkIQ==");

// Decode in strict mode
// Invalid char would cause decoding failure
base64url_decode("SGVsbG8sIHdvcmxkIQ==", true);

Tests

./vendor/bin/phpunit

Benchmarks

Encoding benchmarks:

./vendor/bin/phpbench run benchmarks/encode --report=my_report

Decoding benchmarks:

./vendor/bin/phpbench run benchmarks/decode --report=my_report