library base64
Simple and convenient Base64 encoding and decoding for PHP
delight-im/base64
Simple and convenient Base64 encoding and decoding for PHP
- Monday, July 24, 2017
- by delight-im
- Repository
- 2 Watchers
- 3 Stars
- 3,981 Installations
- PHP
- 1 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 2 Versions
- 43 % Grown
PHP-Base64
Simple and convenient Base64 encoding and decoding for PHP, (*1)
Requirements
Installation
-
Include the library via Composer [?]:, (*2)
$ composer require delight-im/base64
-
Include the Composer autoloader:, (*3)
require __DIR__ . '/vendor/autoload.php';
Usage
Standard
-
Encoding data, (*4)
\Delight\Base64\Base64::encode('Gallia est omnis divisa in partes tres');
// string(52) "R2FsbGlhIGVzdCBvbW5pcyBkaXZpc2EgaW4gcGFydGVzIHRyZXM="
-
Decoding data, (*5)
\Delight\Base64\Base64::decode('R2FsbGlhIGVzdCBvbW5pcyBkaXZpc2EgaW4gcGFydGVzIHRyZXM=');
// string(38) "Gallia est omnis divisa in partes tres"
URL-safe
-
Encoding data, (*6)
\Delight\Base64\Base64::encodeUrlSafe('πάντα χωρεῖ καὶ οὐδὲν μένει …');
// string(80) "z4DOrM69z4TOsSDPh8-Jz4HOteG_liDOus6x4b22IM6_4b2QzrThvbLOvSDOvM6tzr3Otc65IOKApg~~"
-
Decoding data, (*7)
\Delight\Base64\Base64::decodeUrlSafe('z4DOrM69z4TOsSDPh8-Jz4HOteG_liDOus6x4b22IM6_4b2QzrThvbLOvSDOvM6tzr3Otc65IOKApg~~');
// string(58) "πάντα χωρεῖ καὶ οὐδὲν μένει …"
URL-safe without padding
-
Encoding data, (*8)
\Delight\Base64\Base64::encodeUrlSafeWithoutPadding('πάντα χωρεῖ καὶ οὐδὲν μένει …');
// string(78) "z4DOrM69z4TOsSDPh8-Jz4HOteG_liDOus6x4b22IM6_4b2QzrThvbLOvSDOvM6tzr3Otc65IOKApg"
-
Decoding data, (*9)
\Delight\Base64\Base64::decodeUrlSafeWithoutPadding('z4DOrM69z4TOsSDPh8-Jz4HOteG_liDOus6x4b22IM6_4b2QzrThvbLOvSDOvM6tzr3Otc65IOKApg');
// string(58) "πάντα χωρεῖ καὶ οὐδὲν μένει …"
Specifications
Contributing
All contributions are welcome! If you wish to contribute, please create an issue first so that your feature, problem or question can be discussed., (*10)
License
This project is licensed under the terms of the MIT License., (*11)