base64.urlsafe_b64encode and the equal character

Clodoaldo clodoaldo.pinto at gmail.com
Fri Mar 28 09:54:49 EDT 2008


I'm using a md5 hash encoded with base64.urlsafe_b64encode as a
parameter of a URL used to confirm a registration in a site. It has
been working great.

The url is like this:

http://example.com/ce?i=878&h=kTfWSUaby5sBu9bIfoR87Q==

Now i need to match that URL in a certain text and i realized that
urlsafe_b64encode uses the "=" character so i can't just use \w{24} to
match the parameter.

What i need to know is where can an equal char appear in a
urlsafe_b64encoded string?:

a)only at end;
b)both at the end and at the begginig;
c)anywhere in the string;

A sure answer will make my regexp safer.

In another point, does the "=" char make it urlunsafe? I guess not
because i believe it would only be unsafe if the equal appeared like
in "&var=" and since there are no "&" in the string than there is no
problem right? Or wrong?

Regards, Clodoaldo Pinto Neto



More information about the Python-list mailing list