yowcow / mime-base64-urlsafe
PHP-version of URL safe base64 encoding/decoding
Installs: 21 485
Dependents: 2
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >=5.3.29
Requires (Dev)
- phpunit/phpunit: 4.3.*
README
NAME
MIME::Base64URLSafe - URL-safe Base64 Encoder/Decoder
DESCRIPTION
PHP implementation of Perl module MIME::Base64::URLSafe.
SYNOPSIS
Encoding
use \MIME\Base64URLSafe; $output = Base64URLSafe::urlsafe_b64encode('Original Message'); // "T3JpZ2luYWwgTWVzc2FnZQ"
Decoding
use \MIME\Base64URLSafe; $input = Base64URLSafe::urlsafe_b64decode('T3JpZ2luYWwgTWVzc2FnZQ'); // "Original Message"
FUNCTIONS
urlsafe_b64encode($original_string)
Encode a string into base64 string.
urlsafe_b64decode($b64_string)
Decode a base64 string into string.
EXAMPLES
Deflate XML into query string:
$xml = '<hello>world</hello>'; $query_safe_data = Base64URLSafe::urlsafe_b64encode(gzdeflate($xml)); echo http_build_query(array('data' => $query_safe_data), '&');
Inflate XML from query string:
$query_safe_data = $_GET['data']; $xml = gzinflate(Base64URLSafe::urlsafe_b64decode($query_safe_data)); echo $xml;