def decode_base64 ( data : str ) -> bytes : missing_padding = len ( data ) % 4 if missing_padding != 0 : data += "=" * ( 4 - missing_padding ) return base64 . decodebytes ( data . encode ( "utf-8" ) )
python base64 incorrect padding
Decode base64 padding being optional .
def decode_base64(data: str) -> bytes:
    """Decode base64, padding being optional.

    :param data: Base64 data as an ASCII byte string
    :returns: The decoded byte string.
    """
    missing_padding = len(data) % 4
    if missing_padding != 0:
        data += "=" * (4 - missing_padding)
    return base64.decodebytes(data.encode("utf-8"))