"""Security helpers for API key generation and verification."""

import hashlib
import secrets


def generate_api_key() -> str:
    """Generate a URL-safe API key for partner authentication."""
    return secrets.token_urlsafe(32)


def hash_api_key(api_key: str) -> str:
    """Hash an API key using SHA-256 for storage."""
    return hashlib.sha256(api_key.encode("utf-8")).hexdigest()
