question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

question, possible uuid collision

See original GitHub issue

Hi, 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:closed
  • Created 3 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
broofacommented, Apr 22, 2020

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 and shortid. 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.

1reaction
LinusUcommented, Apr 22, 2020

Yes.

You are only getting 9 hexadecimal characters of randomness (9 because one of the 10 will always be -)

Screenshot 2020-04-22 at 15 18 34

ref: https://zelark.github.io/nano-id-cc/

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found