This is Base64Url encoder and decoder written in pure PHP.
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
use function Ieu\Base64Url\base64url_encode;
// Encoding
base64url_encode("Hello, world!");
// Encoding without padding
base64url_encode("Hello, world!", false);
use function Ieu\Base64Url\base64url_decode;
// Decode
base64url_decode("SGVsbG8sIHdvcmxkIQ==");
// Decode in strict mode
// Invalid char would cause decoding failure
base64url_decode("SGVsbG8sIHdvcmxkIQ==", true);
./vendor/bin/phpunit
Encoding benchmarks:
./vendor/bin/phpbench run benchmarks/encode --report=my_report
Decoding benchmarks:
./vendor/bin/phpbench run benchmarks/decode --report=my_report