This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients mahmoudimus, terry.reedy
Date 2011-01-22.01:45:21
SpamBayes Score 8.695957e-09
Marked as misclassified No
Message-id <1295660727.62.0.521131034258.issue10970@psf.upfronthosting.co.za>
In-reply-to
Content
Questions should generally be asked on python-list or its mirrors.

The docs do not say that the result should be exactly, byte-for-byte, the same. base64 module refers to RFC 3548. Both our doc and the RFC describe variations. The base64 codec does 'Mime base64' (7.8.3. Standard Encodings). The RFC says things like "MIME does not define "base 64" per se, but rather a "base 64 Content-Transfer-Encoding" for use within MIME." It also mentions 'line-break issues'.

You neglected to identify and post what the difference is ;-).

>>> import base64
>>> s='I am a string'
>>> s.encode('base64')
'SSBhbSBhIHN0cmluZw==\n'
>>> base64.b64encode(s)
'SSBhbSBhIHN0cmluZw=='
>>> s.encode('base64')== base64.b64encode(s)+'\n'
True

The addition of '\n' for the Mime version looks to be intentional, and will not be changed for 2.7.

(2.5 and 2.6 only get security patches now.)
History
Date User Action Args
2011-01-22 01:45:27terry.reedysetrecipients: + terry.reedy, mahmoudimus
2011-01-22 01:45:27terry.reedysetmessageid: <1295660727.62.0.521131034258.issue10970@psf.upfronthosting.co.za>
2011-01-22 01:45:21terry.reedylinkissue10970 messages
2011-01-22 01:45:21terry.reedycreate