Error on base64.b64decode() ?!
timr at probo.com
Sun Oct 14 06:26:54 CEST 2007
Christoph Krammer <redtiger84 at googlemail.com> wrote:
>On 12 Okt., 17:09, Jean-Paul Calderone <exar... at divmod.com> wrote:
>> If you get an incorrect padding error, try appending a "=" and decoding
>> again. If you get the error again, try appending one more "=". If it
>> still doesn't work, then you might be out of luck.
>This seems to work in some cases, but not all. Whats the deal with
>this adding of "="? Is there an implementation error in python, or are
>other implemenations of base64 more robust then they have to be?
The base64 algorithm converts 3 incoming bytes to 4 encoded bytes. When
you decode base64, the input string MUST be a multiple of 4 bytes. Equal
signs are used to pad the strings to 4n bytes.
The web site you used might be doing that alignment for you.
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list