IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.1.0
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

b64decode

def b64decode(str: StringSpan) -> List[UInt8]

Performs base64 decoding on the input string.

Whitespace (spaces, tabs, newlines, carriage returns, form feeds, and vertical tabs) is ignored, which allows decoding base64 text that has been wrapped across multiple lines. Unlike Python's base64.b64decode, which discards any non-alphabet byte, Mojo only ignores whitespace and still rejects other invalid characters.

Args:

  • ​str (StringSpan): A base64 encoded string.

Returns:

List[UInt8]: The decoded bytes.

Raises:

If the input length (ignoring whitespace) is not divisible by 4, or the input contains a non-whitespace character outside the base64 alphabet.