"""Crypto seam-spec for future post-quantum integration (ADR-005).

Current implementation uses stdlib cryptographic primitives.
When post-quantum algorithms are needed, this module's interface
stays the same — only the implementation changes.

All stdlib only (ADR-007).
"""

from __future__ import annotations

import hashlib
import hmac
import secrets


def hash_sha256(data: bytes) -> str:
    """Compute SHA-256 hash of data, returning hex digest."""
    return hashlib.sha256(data).hexdigest()


def generate_token(nbytes: int = 32) -> str:
    """Generate a cryptographically secure random token."""
    return secrets.token_hex(nbytes)


def constant_time_compare(a: str, b: str) -> bool:
    """Compare two strings in constant time to prevent timing attacks."""
    return hmac.compare_digest(a.encode(), b.encode())
