News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Marcus Bointon's Blog:
PHP Base-62 Encoding
August 11, 2011 @ 11:28:46

In a recent post Marcus Bointon looks at a hashing method that's not one as commonly used by developers as the usual base64 - base-62 encoding that plays a bit nicer with things like URLs and emails due to the character set it allows.

There's a really horrible bug (though they won't call it that!) in Apache's mod_rewrite that means that urlencoded inputs in rewrites get unescaped in their transformation to output patterns. The bug actually remains unfixed, though a workaround first appeared in Apache 2.2.12. [...] Base-62 is interesting as it can be made safe for use in URLs, DNS, email addresses and pathnames, unlike any available encoding of base-64, as it only includes [0-9A-Za-z].

He originally wrote his own parser, but notes that now the BCMath and gmp extensions make it much simpler, just a call to gmp_strval with gmp_init. This method works, but it's still not quite all he wanted so he created his own encoder to do the job.

0 comments voice your opinion now!
base62 base64 encode gmp mcmath extension hash


blog comments powered by Disqus

Similar Posts

DZone.com: The Best Unknown Databases for PHP Apps

Ilia Alshanetsky's Blog: Filter Extension Revamped (and PHP 5.2 news)

Developer.com: SQLite: The Sensible Database Solution

Evert Pot's Blog: Javscript's escape and encodeURI vs. PHP $_POST

Luc de Brouwer's Blog: Never having to use $_GET or $_POST again


Community Events





Don't see your event here?
Let us know!


api list community series introduction interview voicesoftheelephpant podcast deployment laravel conference framework zendserver language tips threedevsandamaybe bugfix symfony code release

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework