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.

I am willing to take a greater risk of collisions for a shorter uuid.

right now I have this:

"file:///home/node/.docker_r2g_cache/83cd49f2-45ba-49ec-9b72-6f84a8adeec7/residence"

I am looking for something more like:

"file:///home/node/.docker_r2g_cache/6f84a8adeec7/residence"

can this library do that or should I use another lib? any recommendations? thx

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
broofacommented, May 28, 2018

I’d suggest using another lib. This lib is specifically for creating RFC4122 UUIDs, which have a specific syntax. If all you care about is length of id, then you’ll want one that draws from a larger set of chars than the 16 hex digits.

Something like https://www.npmjs.com/package/shortid, perhaps? A 21-char id from that lib should have roughly the same chance of collision as the 36-char v4 UUID from this lib.

1reaction
garthkcommented, May 27, 2018

The shorter you make your nonce, the more likely you are to run into collisions. If you know how many unique keys you need, you can calculate the odds: look up “Birthday Paradox”. If you’re OK with the odds, it’s easiest to take a slice of the last ten hex digits of a v4. If you need more bits, take care to not use the bits that indicate which kind of UUID you have: those aren’t random.

Read more comments on GitHub >

github_iconTop Results From Across the Web

short-uuid - npm
Create and translate standard UUIDs with shorter formats.. Latest version: 4.2.2, last published: 2 months ago. Start using short-uuid in ...
Read more >
Short UUID Generator: Short Unique ID
Tiny (4.6kB minified) no-dependency library for generating random or sequential UUID of any length with exceptionally minuscule probabilies of duplicate IDs.
Read more >
oculus42/short-uuid: Translate standard UUIDs into ... - GitHub
short -uuid starts with RFC4122 v4-compliant UUIDs and translates them into other, usually shorter formats. It also provides translators to convert back and ......
Read more >
Generating 8-character only UUIDs - Stack Overflow
It is not possible since a UUID is a 16-byte number per definition. But of course, you can generate 8-character long unique strings...
Read more >
shortuuid - PyPI
shortuuid is a simple python library that generates concise, unambiguous, URL-safe UUIDs. Often, one needs to use non-sequential IDs in places where users ......
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