extended_data.io.base64

This module provides utilities for encoding and decoding data to and from Base64 format.

It includes functions to encode data to Base64 strings, with optional data wrapping for export, and to decode Base64 strings back to their original data.

Module Contents

Functions

base64_encode

Encodes data to base64 format.

base64_decode

Decodes data from base64 format.

API

extended_data.io.base64.base64_encode(raw_data: str | bytes, wrap_raw_data: bool = True) str

Encodes data to base64 format.

Args: raw_data (str | bytes): The data to encode. wrap_raw_data (bool): Whether to wrap the raw data for export.

Returns: str: The base64 encoded string.

extended_data.io.base64.base64_decode(encoded_data: str, unwrap_raw_data: bool = True, encoding: str = 'yaml', *, as_extended: bool = True) Any

Decodes data from base64 format.

Args: encoded_data (str): The base64 encoded string to decode. unwrap_raw_data (bool): Whether to unwrap the raw data after decoding. encoding (str): The encoding format used for wrapping (default is ‘yaml’). as_extended (bool): Wrap decoded values in Tier 2 Extended Data containers.

Returns: Any: The decoded bytes when unwrap_raw_data is False, otherwise the decoded Python object or raw text after UTF-8 decoding.