Axel, that's interesting. I was noticing the same issue, mainly that I have to create uuid's in batches, in the browser, and Date.now() was not granular enough, so they were all getting the same prefix. Didn't seem very useful. Seems like there's no way to create strong, fast uuid's in the browser, but probably good enough for what I'm doing. I will run a test at some point to see how frequently collisions actually occur.
Ted On Aug 7, 2012, at 7:28 AM, Axel Kittenberger <axk...@gmail.com> wrote: > This is what I do to create compact 96 bit UIDs in a fast way. 4 bits > are per 6 characters but thats ok for me. > > var uid = function() { > var mime > ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; > var ua = []; > for(var a = 0; a < 3; a++) { > var r32 = Math.floor(0x100000000 * Math.random()); > for(var b = 0; b < 6; b++) { > ua.push(mime[r32 & 0x3F]); > r32 = r32 >>> 6; > } > } > return ua.join(''); > }; > > I considered adding Date(), but figured it doesnt help me at all for > possible collisions generated in the very moment (from multiple hosts) > It may vary on the use case but I can handle collisions well with UIDs > generated long ago, but not with the ones created in parallell. So in > that case the space taken by Date() is far better used by yet another > random() entity. I also use this notation to save space rather than > the standarized UID type 4 things. > > Yes it is also not cryptographically strong, but in my case that isn't > an issue and speed is more important. Also the web clients need to be > able to create UIDs and that cancels out a lot possibilities anyway > that might be available in node. > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to nodejs@googlegroups.com > To unsubscribe from this group, send email to > nodejs+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en