diff options
Diffstat (limited to 'Lib/base64.py')
-rwxr-xr-x | Lib/base64.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Lib/base64.py b/Lib/base64.py index adaec1de61..58f6ad6816 100755 --- a/Lib/base64.py +++ b/Lib/base64.py @@ -55,8 +55,7 @@ def b64encode(s, altchars=None): alternative alphabet for the '+' and '/' characters. This allows an application to e.g. generate url or filesystem safe Base64 strings. """ - # Strip off the trailing newline - encoded = binascii.b2a_base64(s)[:-1] + encoded = binascii.b2a_base64(s, newline=False) if altchars is not None: assert len(altchars) == 2, repr(altchars) return encoded.translate(bytes.maketrans(b'+/', altchars)) @@ -156,7 +155,7 @@ def b32encode(s): leftover = len(s) % 5 # Pad the last quantum with zero bits if necessary if leftover: - s = s + bytes(5 - leftover) # Don't use += ! + s = s + b'\0' * (5 - leftover) # Don't use += ! encoded = bytearray() from_bytes = int.from_bytes b32tab2 = _b32tab2 |