base64.encode and decode not correct

Fredrik Lundh fredrik at pythonware.com
Tue Aug 16 14:49:05 CEST 2005


Damir Hakimov wrote:

> I found a strange bug in base64.encode and decode, when I try to encode
> - decode a file 1728512 bytes lenth.

does this work on your machine?

>>> import base64
>>> x = base64.encodestring(1728512 * "*")
>>> len(base64.decodestring(x))
1728512

does it work also if you change it to

>>> import base64
>>> data = open(FILENAME, "rb").read()
>>> x = base64.encodestring(data)
>>> len(base64.decodestring(x))

(where FILENAME is the name of your file)

?

</F> 






More information about the Python-list mailing list