[docs] binascii.b2a_base64 can convert data length more than 57
Georg Brandl
georg at python.org
Sun Oct 6 12:41:39 CEST 2013
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am 05.06.2013 05:09, schrieb Chen, Liying:
> Hi,
>
>
>
> In the document binascii.b2a_base64(data) said the data length should less
> than 57.But I can use it for more than 57.Can you give me an explain?
>
>
>
>>>> import struct import binascii payload =
>>>> struct.pack('>hhiii',4,0,0,0,0) payload = payload*10 len(payload)
> 160
>>>> binascii.b2a_base64(payload)
> 'AAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAA==\n'
>>>>
>
a = binascii.b2a_base64(payload)
>>>> len(a)
> 217
>>>>
Hi Liying,
the function itself can process arbitrary lengths. The documentation just
states that if you want the *result* to be compatible to the base64 standard,
the input should be <= 57 characters in length.
cheers,
Georg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.21 (GNU/Linux)
iEYEARECAAYFAlJRPmMACgkQN9GcIYhpnLDK9gCglvQZYDlpj+aCw3//PwxWOWyo
pMoAnivHlRIPjlXuBDkfy/xGFdiGllKS
=7eiH
-----END PGP SIGNATURE-----
More information about the docs
mailing list