Skip to main content

UUIDv5

UUIDv5 is a name-based, deterministic UUID — just like UUIDv3 — but it uses SHA-1 hashing instead of MD5, making it more secure and reliable for long-term use.

It produces the same UUID for a given (namespace + name) pair.

Generate a UUIDv5

use DomainFlow\Uuid\UuidV5;

$namespace = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; // DNS
$name = 'example.com';

$uuid = UuidV5::generate($namespace, $name);

Validate a UUIDv5

UuidV5::isValid('2ed6657d-e927-568b-95e1-2665a8aea6a2');

Inspector Output

use DomainFlow\Uuid\Inspector;

$metadata = Inspector::analyze((string) $uuid)->metadata();

Returns:

[
'hash_type' => 'SHA-1',
'deterministic' => true,
'note' => 'UUIDv5 encodes a hash of namespace + name'
]

Standard Namespaces

Just like v3, UUIDv5 supports these common namespaces:

  • 6ba7b810-9dad-11d1-80b4-00c04fd430c8 – DNS
  • 6ba7b811-9dad-11d1-80b4-00c04fd430c8 – URL
  • 6ba7b812-9dad-11d1-80b4-00c04fd430c8 – ISO OID
  • 6ba7b814-9dad-11d1-80b4-00c04fd430c8 – X.500 DN

Use Cases

  • Stable, globally unique IDs derived from namespaces + identifiers
  • Safer than UUIDv3 thanks to SHA-1 over MD5
  • Use in deterministic systems, caching, or inter-service ID generation

Pro tip: Prefer UUIDv5 over UUIDv3 if you want deterministic UUIDs and care about hash strength or future compatibility.