import base64 def bytes_to_string(data: bytes) -> str: return base64.b64encode(data).decode() def string_to_bytes(data: str) -> bytes: return base64.b64decode(data.encode())