Skip to content

yowcow/php-mime-base64-urlsafe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

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), '&amp;');

Inflate XML from query string:

$query_safe_data = $_GET['data'];

$xml = gzinflate(Base64URLSafe::urlsafe_b64decode($query_safe_data));

echo $xml;

About

PHP-version of URL safe base64 encoding/decoding

Resources

Stars

Watchers

Forks

Packages

No packages published