paralleldrive / cuid

Collision-resistant ids optimized for horizontal scaling and performance.
Other
3.44k stars 123 forks source link

Fixed the potential overflow in the slug() method. #9

Closed moonpyk closed 10 years ago

moonpyk commented 10 years ago

Implemented a safeCounter() function that returns a safe value and auto increments the counter. Calls from other APIs have been modified to always make use of it, instead of direct use of the c var. Fixes #8

ericelliott commented 10 years ago

Thanks!

ericelliott commented 10 years ago

While reviewing this patch, I discovered a major flaw in the slug algorithm -- it wasn't doing enough to protect against collisions -- I was able to produce collisions easily. I have patched it and increased collision defense by several orders of magnitude. Please update your implementation to reflect the change.

See https://github.com/dilvie/cuid/issues/10