sporkmonger / uuidtools

A simple universally unique ID generation library.
http://uuidtools.rubyforge.org/
Apache License 2.0
424 stars 63 forks source link

Is sha1_generate supposed to give the same value for every invocation with the same namespace? #19

Closed timuckun closed 11 years ago

timuckun commented 11 years ago

UUIDTools::UUID.sha1_create(UUIDTools::UUID_DNS_NAMESPACE, "http://github.com").to_s => "de33c012-0cb8-5281-8f42-768c47f00bd7"

UUIDTools::UUID.sha1_create(UUIDTools::UUID_DNS_NAMESPACE, "http://github.com").to_s => "de33c012-0cb8-5281-8f42-768c47f00bd7"

sporkmonger commented 11 years ago

Yes. It's using the namespace plus a value that's already guaranteed to be unique to generate the UUID. Do not use this variant if the underlying data is not already guaranteed to be universally unique.

sporkmonger commented 11 years ago

I should add, DNS namespace is the hostname only. The example you gave would be incorrect. So "github.com" not "http://github.com".