3 ms·
cuid [0] seems to be a random letter, concatenated with a sha3 hash of: - the system time - a process-global singleton counter (incrementing with each ID) -
by kiitos 3y ago
cuid [0] seems to be a random letter, concatenated with a sha3 hash of:
- the system time
- a process-global singleton counter (incrementing with each ID)
- a "salt" derived from some number of bytes taken from an entropy source
- a "fingerprint" of some number of bytes taken from the same entropy source
this is an awful lot of work to be doing for each ID, to what end? well issue 7 [1] says that
> Cuid2 is good when you need something secure, extremely collision resistant, and your system is distributed or decentralized (e.g. you want to be able to create records with ids on the client side), or you are building software that may need to scale horizontally).
but I'm not sure how cuid as implemented provides a better answer in any of these dimensions to a plain old UUID
maybe I'm just being cynical, I dunno
[0] https://github.com/paralleldrive/cuid2/blob/fb07094487ba5ad038a51ef67bcb9c5f525c173b/src/index.js#L97 https://github.com/paralleldrive/cuid2/blob/fb07094487ba5ad0...
[1] https://github.com/paralleldrive/cuid2/issues/7 https://github.com/paralleldrive/cuid2/issues/7