Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Just use v7.

Cue the security experts who say otherwise…



Use v4 if creation date could conceivably be sensitive information of if you depend on your uuids being completely unguessable. Otherwise use v7


If we want a v7, shouldn't we use a ULID instead?


When we didn't have UUIDv7, ULID was great. But now that we have v7 it's the more widely supported alternative. And apart from v7 setting the UUID version bits and having a different default representation they are not that different.


ULID's presentation format is probably better for humans, though. You can double-click-to-highlight a ULID; the standard UUID representation doesn't like this.

(You can use ULID's presentational tools with UUIDv7, though.)


It doesn't help in other tools, but there is a css rule to help with this.

https://developer.mozilla.org/en-US/docs/Web/CSS/user-select


> You can use ULID's presentational tools with UUIDv7, though.

I did that, works pretty good: https://codeberg.org/prettyid/python

Some more context in a sibling thread: https://news.ycombinator.com/item?id=41355218


> You can double-click-to-highlight a ULID; the standard UUID representation doesn't like this.

You can control this behavior in CSS with `user-select`. Peep my fiddle: https://jsfiddle.net/gLyph5km/


Yup, in a browser you can. In my terminal or my text editor or Slack, I can't.


You're right that there isn't a good standard way to configure this, but a lot of terminals should be able to do it. The magic phrase is “word characters”. I know Konsole, gnome-terminal, iTerm2, Terminal-dot-app at least have this setting.


Yep, I know about that (and WORDCHARS in zsh, for keyboard navigation). The thing is, though, UUIDs overload the dash character. I don't want dashes to be word characters except for a UUID.

(ULID representations also are shorter because they use a wider character set, which is nice though not critical.)


> the standard UUID representation doesn't like this.

Yeah, I've gotten in the habit of stripping hyphens from the string representation of UUIDs in a lot of the code I write for that reason.


Yeah I’m sticking with ULID and Sqids for my ID/slug purposes.


Oh, I didn't realize v7 was newer than ULID, thanks.


Be careful if you're using python.

The python uuid standard library doesn't have V7 yet, and there is a package called uuid7 which is unmaintained, and not in compliance with the latest standard. That's using nanosecond time precision rather than millisecond, which means the leading bits are larger than they are meant to be.

If you use that unmaintained uuid7 package and later change to the correct implementation your uuid7 will go backwards, which is a breaking change considering that monotonicity is a key property of uuidv7.


I believe your concern, while valid, only affects systems which are currently adding records faster than 1 per nano-second on occasion.

Also while technically true - it could technically break monotonicity (records added in the same nanosecond could be out of order) they'll still be all "near the end of the file, likely in the same page" such that performance implications are negligible.

As a general rule I would avoid any program making any assumptions about a uuid. Programs should treat it as an opaque binary random value. Doing so avoids any future incompatibilities.


An issue I've always had with UUIDs and ULIDs is there isn't a great way to generate one deterministically, as far as I can tell: for a lot of use-cases, being able to reprocess data and generate identical IDs is really useful and there isn't a standard way that I know of to achieve this.


That's UUID v5 (uses a sha1 hash of input data).


Are you looking for something other than just a custom seed in the RNG?



Sure, there are workarounds in various languages, but it would nice to have a standardized hash-based UUID or ULID


If it's a standardized sequence, then that's no different than just 0, 1, 2, 3 but with different names. If you just want a non-sequential but deterministic sequence, then that's every random number generator that accepts a seed value, and being anymore standardized than that makes zero sense.


The problem with autoincrement in this context is you can’t reproduce the right value when replaying the input streams for your stream processing job. Hashing some combination of values and using that as a primary key solves this problem nicely and, when you’re using bitemporal data modeling, makes it easy to correct mistakes. The point of standardization is compatibility, not standardizing the sequence of keys used.


I agree on all points you're making, but you can't standardize on hashing when the data being hashed will vary due to business reasons. I just can't see any way that this can be realistically standardized outside of a single business, maybe even business-unit depending on the kind of company.

Perhaps you mean something like "standardized hash of all columnar data for the table row," but then you're just reinventing elasticsearch/lucene, with all its pros and cons. The power of foreign keys for a RDBS is that they are pointers, and as pointers, the mutability of their underlying data is what makes them powerful. I think I get what you're asking for, but I also think there can be no possible standard that is reasonable unless you have the technology to take a total snapshot of the universe, at which point, why not just measure the universe itself as your database? Perfect storage system.


from the article, it sounds like this is V5?


I missed that because I typically am using ULIDs these days. But, yeah, some standardized format for a hash of message data is what I want.


why wouldn't you use some sort of collision resistant hashing function on the data to achieve this instead?


Some systems expect UUIDs so you don't always have that choice.


v5... I use them all the time.


Why are you dismissive of security-related issues?


Because developers don't always consider the security aspect. Not saying this is what he's doing but could also just be due to how complex good software can be to write.

Their is a reason cybersecurity or UI/UX or product design isn't always left to the developer. The coder write code that fits certain criteria they are given, then someone down the line might QA check it, fuzz inputs or security review the code. How well this is done depends on the product,market, and environment.


I’m not dismissive of security related issues. My comment was a snarky reference to some other HN comments on uuid7 some time ago which I’m having trouble finding now. The comment was lamenting developers using uuid7 for many things, presumably without thought, creating loads of security issues for them.

In most cases creation time is not sensitive. Therefore, for most cases uuid7 is the best trade off currently.


Because at least half if not more of the industry sector is charlatans. Similar to how devs love to work on new shiny tech, regardless of its actual applicability to their needs, security folk will often insist that X is insecure due to absurdly unlikely edge case wherein you’re already pwned anyway, while ignoring some basic problem in their org.


That doesn't mean that it's not a valid concern in some cases, and it's good to be aware of it. When you're building something, and need a UUID, and stop think "v7 seems useful, but wait, wasn't there a security thing?", that's a win. Even if the answer turns out to be "not a problem in this case".




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: