import uuid
from pathlib import Path

STORAGE_ROOT = Path("data/blobstore")

async def save_encrypted_payload(payload_b64: str) -> str:
    STORAGE_ROOT.mkdir(parents=True, exist_ok=True)
    key = f"{uuid.uuid4()}.blob"
    path = STORAGE_ROOT / key
    path.write_text(payload_b64, encoding="utf-8")
    return key

async def load_encrypted_payload(path_key: str) -> str:
    path = STORAGE_ROOT / path_key
    return path.read_text(encoding="utf-8")
