sha1UUID

This function generates a name based (Version 5) UUID from a namespace UUID and a name. If no namespace UUID was passed, the empty UUID UUID.init is used.

Note: The default namespaces (dnsNamespace, ...) defined by this module should be used when appropriate.

CTFE: CTFE is not supported.

Note: RFC 4122 isn't very clear on how UUIDs should be generated from names. It is possible that different implementations return different UUIDs for the same input, so be warned. The implementation for UTF-8 strings and byte arrays used by std.uuid is compatible with Boost's implementation. std.uuid guarantees that the same input to this function will generate the same output at any time, on any system (this especially means endianness doesn't matter).

Note: This function does not provide overloads for wstring and dstring, as there's no clear answer on how that should be implemented. It could be argued, that string, wstring and dstring input should have the same output, but that wouldn't be compatible with Boost, which generates different output for strings and wstrings. It's always possible to pass wstrings and dstrings by using the ubyte[] function overload (but be aware of endianness issues!).

  1. UUID sha1UUID(const(char)[] name, UUID namespace)
  2. UUID sha1UUID(const(ubyte)[] data, UUID namespace)
    @safe pure nothrow @nogc
    sha1UUID
    (
    scope const(ubyte)[] data
    ,
    scope const UUID namespace = UUID.init
    )

Examples

//Use default UUID.init namespace
auto simpleID = sha1UUID("test.uuid.any.string");

//use a name-based id as namespace
auto namespace = sha1UUID("my.app");
auto id = sha1UUID("some-description", namespace);

Meta