extmod/modubinascii: Add newline keyword to b2a_base64 function.

This allows encoding things (eg a Basic-Auth header for a request) without
slicing the \n from the string, which allocates additional memory.

Co-authored-by: David Lechner <david@lechnology.com>
This commit is contained in:
Christian Decker
2022-01-15 15:19:59 +01:00
committed by Damien George
parent aafd8859e9
commit 2e3a2785cd
3 changed files with 21 additions and 8 deletions

View File

@@ -31,8 +31,8 @@ Functions
Conforms to `RFC 2045 s.6.8 <https://tools.ietf.org/html/rfc2045#section-6.8>`_.
Returns a bytes object.
.. function:: b2a_base64(data)
.. function:: b2a_base64(data, *, newline=True)
Encode binary data in base64 format, as in `RFC 3548
<https://tools.ietf.org/html/rfc3548.html>`_. Returns the encoded data
followed by a newline character, as a bytes object.
followed by a newline character if newline is true, as a bytes object.