note 103849 modified in function.base64-encode by danbrown
| From: | danbrown@php.net | Date: | Fri, 06 May 2011 16:13:30 +0000 |
| Subject: | note 103849 modified in function.base64-encode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-179499@lists.php.net to get a copy of this message | ||
For anyone interested in the 'base64url' variant encoding, you can use this pair of
functions:
<?php
function base64url_encode($data) {
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
function base64url_decode($data) {
return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4,
'=', STR_PAD_RIGHT));
}
?>
--was--
For anyone interested in the 'base64url' variant encoding, you can use this pair of
functions:
function base64url_encode($data) {
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
function base64url_decode($data) {
return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4,
'=', STR_PAD_RIGHT));
}
http://php.net/manual/en/function.base64-encode.php