from typing import ByteString
import base64


def encode_bytes(b: ByteString) -> str:
    """Encode the binary data to a string.

    Args:
        b: Binary data to encode.

    Returns:
        WAMP JSON string representation of the binary data.
    """
    e = b"\0" + base64.b64encode(b)
    return e.decode()