Return to Snippet

Revision: 62367
at February 19, 2013 21:12 by apphp-snippets


Initial Code
<?php
function base64url_encode
($text){
    $base64 = base64_encode
($text);
    $base64url = strtr($base64, '+/=', '-_,');
    return $base64url;
}
 
function base64url_decode
($text){
    $base64url = strtr($text, '-_,', '+/=');
    $base64 = base64_decode
($base64url);
    return $base64;
}
?>

Initial URL
http://www.apphp.com/index.php?snippet=php-base64-encode-and-decode-string

Initial Description
Encodes the given data with MIME base64. Base64-encoded data takes about 33% more space than the original data.

Initial Title
Base64 Encode and Decode String in PHP

Initial Tags
php

Initial Language
PHP