modified base64
| From: | (Marcus Boerger) | Date: | Wed, 10 Apr 2002 14:03:22 +0000 |
| Subject: | modified base64 | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-82481@lists.php.net to get a copy of this message | ||
After (v)spprintf i have another modified function here: base64url_(en|de)code
I sometimes transmit binary data or thinks like session ids over http. when
using base64 the problem is in the chars '+', '/' and '='. So i changed base64
to use '-', '_' and '!' instead. After this change no modification is done to the
string as with the '+' sign and i do not have the problems of '=', '/' which would
have to be url encoded what makes the string longer. In fact the 65 characters
i use now are those 71 characters which have neither a protocol function nor
have to be encoded (RFC1321). As these characters have no meaning in
filesystems as well things like session ids (len % 4 == 0) which are often used
for filenames as well can have shorter names with this encoding. And last but
not least these characters have no meaning with regular expressions.
In addition i could make the functions accept hexadecimal values as well
because (i suppose) in most such cases the input/output is hexadecimal.
Reference: RFC1321 MD5, RFC2396 URI, RFC2616 HTTP
Any comments?
marcus
-------->>> mailto:marcus.boerger@post.rwth-aachen.de <<<----------
"Man will never reach the moon,
regardless of all future scientific advances"
Dr. Lee de Forest, inventor of the Audion tube
and father of the radio, Feb. 25, 1967--------------->>> http://www.marcus-boerger.de <<<----------------