Comments on base52 encoder/decoder ?

Bengt Richter bokr at oz.net
Tue Jan 7 08:38:40 EST 2003


On Mon, 06 Jan 2003 20:21:34 -0800, Erik Max Francis <max at alcyone.com> wrote:

>Bengt Richter wrote:
>
>> What it boils down to is that there are enough codes for two sets
>> of encodings plus 9023 special codes. You can think of it as a single
>> bit attribute for arbitrary subsequences of binary bytes with no extra
>> encoding characters vs doing them separately as before, and 9023
>> integer
>> codes can be inserted also at a cost of 3 code characters apiece. You
>> can think of them as available escape codes.
>
>My initial, gut reaction to this is that you're getting too fancy for
>your own good.
>
Was it the extras, or just putting too much on the plate at once? ;-)

What if I had just started with the default encoding/decoding
and showed one useful example?

E.g., it makes a nice safe all-alpha hash string from md5
(that is also 25% shorter than hex):

 >>> import base52x
 >>> b2a = base52x.b2a_base52
 >>> a2b = base52x.a2b_base52
 >>> import md5

 >>> md5.new("Nobody inspects the spammish repetition").digest()
 '\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9'

 >>> md5.new("Nobody inspects the spammish repetition").hexdigest()
 'bb649c83dd1ea5c9d9dec9a18df0ffe9'

 >>> b2a(md5.new("Nobody inspects the spammish repetition").digest())
 'RmcOqbUwePkJUgeTEhNWoYLt'


Verifying that the info is all there (for this case ;-):

 >>> a2b('RmcOqbUwePkJUgeTEhNWoYLt')
 '\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9'

Regards,
Bengt Richter




More information about the Python-list mailing list