"""Stable machine fingerprint for tying a local CNPERP install to one server."""
from __future__ import annotations

import hashlib
import platform
import socket
import uuid


def get_machine_fingerprint() -> str:
    """Return a stable-ish host identifier (not cryptographically secret)."""
    parts = [
        platform.system(),
        platform.machine(),
        socket.gethostname(),
        str(uuid.getnode()),
    ]
    raw = "|".join(p.strip().lower() for p in parts if p)
    return hashlib.sha256(raw.encode("utf-8")).hexdigest()[:32]
