Recommend this page to a friend! |
![]() ![]() |
Info | ![]() |
![]() |
![]() ![]() |
Reputation | Support forum (1) | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
![]() ![]() ![]() ![]() | Total: 150 | All time: 9,030 This week: 115![]() |
Version | License | PHP version | Categories | |||
oirebase64 1.0 | MIT/X Consortium ... | 5 | PHP 5, Text processing |
Description | Author Andre Polykanine also known as Menelion Elensúlë Contributor | |
This class can perform URL safe encoding and decoding of data with Base64. Innovation Award |
Encodes data to Base64 URL-safe way and decodes encoded data. Note: This package requires PHP 7.1 or above.
use \Oire\Base64;
$text = "The quick brown fox jumps over the lazy dog";
try {
$encoded = Base64::encode($text);
} catch(Exception $e) {
// Handle errors
}
echo $encoded.PHP_EOL;
This will output:
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.:
try {
$encoded = Base64::encode($text, true);
} catch(Exception $e) {
// Handle errors
}
echo $encoded.PHP_EOL;
This will output:
VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw~~
To decode the data, simply call decode()
:
$encoded = "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw";
try {
$decoded = Base64::decode($encoded);
} catch(Exception $e) {
// Handle errors
}
echo $decoded.PHP_EOL;
This will output:
The quick brown fox jumps over the lazy dog
Via Composer:
composer require oire/base64
or manually:
require_once("oire/base64.php");
Run phpunit
in the projects directory.
Copyright © 2017, Andre Polykanine also known as Menelion Elensúlë. This software is licensed under an MIT license.
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Aux. | Auxiliary script | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Lic. | License text | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Doc. | Documentation |
Version Control | Reuses | Unique User Downloads | Download Rankings | ||||||||||||||||
100% | 2 |
|
|
User Ratings | User Comments (1) | ||||||||||||||||||||||||||||||||||
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.
Other classes that need this package |
Class | Why it is needed | Dependency |
---|---|---|
Oire Colloportus | Needed to transform binary data into a storable form. | Required |
Oire Serializer | Needed for encoding serialized data to Url-safe base64. | Conditional |