note 63543 added to function.base64-encode
| From: | massimo dot scamarcia at gmail dot com | Date: | Thu, 23 Mar 2006 11:02:14 +0000 |
| Subject: | note 63543 added to function.base64-encode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-106467@lists.php.net to get a copy of this message | ||
function urlsafe_b64encode($string) {
$data = base64_encode($string);
$data =
str_replace(array('+','/','='),array('-','_',''),$data);
return $data;
}
function urlsafe_b64decode($string) {
$data = str_replace(array('-','_'),array('+','/'),$string);
$mod4 = strlen($data) % 4;
if ($mod4) {
$data .= substr('====', $mod4);
}
return base64_decode($data);
}
Php version of perl's MIME::Base64::URLSafe, that provides an url-safe base64 string
encoding/decoding (compatible with python base64's urlsafe methods)
----
Server IP: 213.92.11.19
Probable Submitter: 195.110.97.5
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.base64-encode.php
Edit -- http://master.php.net/note/edit/63543
Del: integrated -- http://master.php.net/note/delete/63543/integrated
Del: useless -- http://master.php.net/note/delete/63543/useless
Del: bad code -- http://master.php.net/note/delete/63543/bad+code
Del: spam -- http://master.php.net/note/delete/63543/spam
Del: non-english -- http://master.php.net/note/delete/63543/non-english
Del: in docs -- http://master.php.net/note/delete/63543/in+docs
Del: other reasons-- http://master.php.net/note/delete/63543
Reject -- http://master.php.net/note/reject/63543
Search -- http://master.php.net/manage/user-notes.php