2017 © Pedro PelĂĄez
 

library base64

URL-and filename-safe Base64 handling.

image

oire/base64

URL-and filename-safe Base64 handling.

  • Saturday, April 8, 2017
  • by Oire
  • Repository
  • 1 Watchers
  • 2 Stars
  • 61 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 13 % Grown

The README.md

Oirë Base64, URL-safe Base64 Handling

Note! This library is not maintained anymore.

Please use Iridium security library instead., (*1)

Latest Version on Packagist MIT License, (*2)

Encodes data to Base64 URL-safe way and decodes encoded data., (*3)

Requirements

This library requires PHP 7.3 or above., (*4)

Installation

Install via Composer:, (*5)

composer require oire/base64

Running Tests

Run ./vendor/bin/phpunit in the project directory., (*6)

Compatibility with Earlier Versions of PHP

If you want a version compatible with PHP 7.1.2, please install version 1 instead:, (*7)

composer require "oire/base64 ^1"

Usage Examples

use Oire\Base64\Base64;
use Oire\Base64\Exception\Base64Exception;

$text = "The quick brown fox jumps over the lazy dog";
$encoded = Base64::encode($text);
echo $encoded.PHP_EOL;

This will output:, (*8)

VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw

By default, the encode() method truncates padding = signs as PHP’s built-in decoder handles this correctly. However, if the second parameter is given and set to true, = signs will be replaced with tildes (~), i.e.:, (*9)

$encoded = Base64::encode($text, true);
echo $encoded.PHP_EOL;
````

This will output:  
```shell
VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw~~

To decode the data, simply call Base64::decode():, (*10)

$encoded = "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw";

try {
    $decoded = Base64::decode($encoded);
} catch(Base64Exception $e) {
    // Handle errors
}

echo $decoded.PHP_EOL;

This will output:, (*11)

The quick brown fox jumps over the lazy dog

License

Copyright © 2017-2021, Andre Polykanine also known as Menelion ElensĂșlĂ«, The Magical Kingdom of OirĂ«.
This software is licensed under an MIT license., (*12)

The Versions

08/04 2017

dev-master

9999999-dev

URL-and filename-safe Base64 handling.

  Sources   Download

MIT

The Requires

  • php >= 7.1

 

The Development Requires

encoding decoding base64 url-safe single-file

26/03 2017

v1.1

1.1.0.0

URL-and filename-safe Base64 handling.

  Sources   Download

MIT

The Requires

  • php >= 7.1

 

The Development Requires

encoding decoding base64 url-safe single-file

19/03 2017

v1.0

1.0.0.0

URL-and filename-safe Base64 handling.

  Sources   Download

MIT

The Requires

  • php >= 7.1

 

The Development Requires

encoding decoding base64 url-safe single-file