rse / pure-uuid

Pure JavaScript Based Universally Unique Identifiers (UUID)
https://www.npmjs.com/package/pure-uuid
66 stars 16 forks source link

non-unique v5 IDs are generated #7

Closed sean9999 closed 7 years ago

sean9999 commented 7 years ago

using the following invocation, non-unique IDs are generated:

let a = new UUID(5, "ns:URL", "http://example.com/").format();
let b = new UUID(5, "ns:URL", "http://example.com/").format();
let c = new UUID(5, "ns:URL", "http://example.com/").format();

console.log({a,b,c})

Expected behaviour: The values should be unique

rse commented 7 years ago

Errr... no, the values of UUID v5 identifiers are only unique for different values. If you pass in always just "http://example.com/" you will always get return the same UUID. This is fully correct. Please check the UUID standard and understand the differences between the different UUID versions. UUID v1 is node-based, v3/v5 are hash-based and v4 is random-number based.