Skip to main content

Module sid

Module sid 

Source
Expand description

Per-user identity hash used by every broker pipe name.

Returns a 16-character lowercase hex string (the first 8 bytes of a blake3 digest, hex-encoded). Stable across runs for the same user on the same machine; collision resistant in practice.

§Platform inputs

PlatformHash input
WindowsThe current process token user SID, in S-1-... text form, obtained via OpenProcessToken(GetCurrentProcess())GetTokenInformation(TokenUser)ConvertSidToStringSidW.
Linuxformat!("{uid}:{machine_id}") where machine_id is the contents of /etc/machine-id, falling back to /var/lib/dbus/machine-id.
macOSformat!("{uid}:{machine_uuid}") where machine_uuid comes from ioreg -d2 -c IOPlatformExpertDevice (the IOPlatformUUID field).

§Why a hash?

Pipe-name length limits are tight: Windows MAX_PATH (260) and the macOS sun_path field (104 bytes). A blake3 16-char hex is short, collision-resistant for the namespace size we care about (per-machine per-user), and avoids leaking the literal SID or machine UUID into world-readable filesystem paths.

Enums§

SidError
Errors that can prevent computing the user SID hash.

Functions§

hash_to_16_hex
Hash arbitrary bytes to 16 lowercase hex characters using blake3.
user_sid_hash
Return the 16-character lowercase hex blake3 hash of the current user’s platform identity. Stable across runs.