question, possible uuid collision
See original GitHub issueHi, I’ve seen some projects doing this with this package: v4().substr(0, 10)
to only take the 10 first characters of the UUID.
Is this creating a risk of collision ?
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Has there ever been a UUID collision? - Quora
Definitely yes. If you generate 1 billion type 4.1 truly random UUID values per second for 85 years, there is a 50 percent...
Read more >How big is the chance to get a Java UUID.randomUUID ...
In other words, creating UUIDs from different computers does not change anything, it is incredibly unlikely that a collision will occur. In fact,...
Read more >UUID collisions [closed] - Software Engineering Stack Exchange
A "random" UUID has 122 random bits. Assuming perfect randomness, you can expect the first collision at around 2^61 generated UUIDs (that's the ......
Read more >A UUID can have so many combinations that UUIDs ... - Reddit
Yes the chances are very low, theoretically astronomically low, but in practice in programming, collisions do and have happened, especially ...
Read more >Universally Unique Identifiers - Level Up Coding
A collision occurs when the same UUID is generated twice. Understanding the probability of a collision in each version may decide the best ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
At the risk of being pedantic, a “10 char UUID” is an oxymoron. “UUID” has a very specific definition (see RFC 4122). tl;dr - they are 128-bit values that, when formatted as strings, have 32 hex characters and four ‘-’ chars.
There are many libraries out there for generating unique IDs of various flavors. E.g.
nanoid
andshortid
. Just be aware that you’re venturing into “non-standard” territory and don’t expect such IDs to play nice in contexts (like databases) that have built-in support for UUIDs.Yes.
You are only getting 9 hexadecimal characters of randomness (9 because one of the 10 will always be
-
)ref: https://zelark.github.io/nano-id-cc/