File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ def b32encode(s):
166166 if leftover :
167167 s = s + bytes (5 - leftover ) # Don't use += !
168168 quanta += 1
169- encoded = bytes ()
169+ encoded = bytearray ()
170170 for i in range (quanta ):
171171 # c1 and c2 are 16 bits wide, c3 is 8 bits wide. The intent of this
172172 # code is to process the 40 bits in units of 5 bits. So we take the 1
@@ -187,14 +187,14 @@ def b32encode(s):
187187 ])
188188 # Adjust for any leftover partial quanta
189189 if leftover == 1 :
190- return encoded [: - 6 ] + b'======'
190+ encoded [- 6 :] = b'======'
191191 elif leftover == 2 :
192- return encoded [: - 4 ] + b'===='
192+ encoded [- 4 :] = b'===='
193193 elif leftover == 3 :
194- return encoded [: - 3 ] + b'==='
194+ encoded [- 3 :] = b'==='
195195 elif leftover == 4 :
196- return encoded [: - 1 ] + b'='
197- return encoded
196+ encoded [- 1 :] = b'='
197+ return bytes ( encoded )
198198
199199
200200def b32decode (s , casefold = False , map01 = None ):
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ Core and Builtins
2424Library
2525-------
2626
27+ - Issue #17812: Fixed quadratic complexity of base64.b32encode().
28+
2729- Issue #17980: Fix possible abuse of ssl.match_hostname() for denial of
2830 service using certificates with many wildcards (CVE-2013-2099).
2931
You can’t perform that action at this time.
0 commit comments