UUIDv2
UUIDv2 is a DCE Security UUID — designed to include domain-specific information such as a POSIX UID or GID, along with timestamp and randomness.
It replaces part of the timestamp with a local identifier and adds a domain byte.
Generate a UUIDv2
You can generate a UUIDv2 by specifying a domain and a local identifier:
use DomainFlow\Uuid\UuidV2;
$uuid = UuidV2::generate(1000, 'uid'); // or 'gid'
echo (string) $uuid;
Validate a UUIDv2
UuidV2::isValid('f47ac10b-58cc-21ec-8f4c-0242ac120002');
Inspect with Inspector
use DomainFlow\Uuid\Inspector;
$metadata = Inspector::analyze((string) $uuid)->metadata();
You’ll get:
[
'domain' => 'POSIX UID',
'local_identifier' => 1000,
'note' => 'UUIDv2 replaces timestamp low bits with a UID/GID'
]
Domains
'uid'
: POSIX User ID'gid'
: POSIX Group ID
Invalid domain values (e.g. 'banana'
) will throw an exception.
Use Cases
- Secure, identity-bound UUIDs (e.g. for user-scoped sessions or audit trails)
- Systems that require both time ordering and user context
- DCE/RPC-based systems or applications requiring UID/GID encoding
⚠️ Note: UUIDv2 is not widely used in modern systems but is supported here for legacy or security-sensitive use cases.